News for hackers. Stuff that matters.
Re:Objective-C Memory Management For Lazy People by msbarnett on Thursday December 09, 2010 @04:11AM (#1986716)
Not necessarily. If you want to avoid situations where title points at a mutable subclass, yes, but if that isn't a concern, there's nothing inherently incorrect with a simple retain.
Re:Objective-C Memory Management For Lazy People by jckarter on Thursday December 09, 2010 @05:16AM (#1986869)
"copy"ing an immutable string just retains it, so there's little benefit to using a retain property for NSString properties, or for properties of the other NSMutableCopying type families. As a best practice you should always use copy properties for them.
Re:Objective-C Memory Management For Lazy People by ajg1977 on Thursday December 09, 2010 @04:44AM (#1986801)
Except that if someone modifies the string they passed you, your 'copy' of the string will also change.
Re:Objective-C Memory Management For Lazy People by naz on Thursday December 09, 2010 @05:42AM (#1986925)
That would only occur if it was an NSMutableString, like the GP said.