As someone that's new to Objective-C can someone give me an overview of the retain, assign, copy and any others I'm missing, that follow the @property directive? What are they doing and why would I want to use one over another?
Thanks
As someone that's new to Objective-C can someone give me an overview of the retain, assign, copy and any others I'm missing, that follow the @property directive? What are they doing and why would I want to use one over another?
Thanks
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html, section 'attributes'. First result on Google for 'apple @property objective c'.
"retain" returns a retained reference to your object (caller's responsibility to release / dispose of it / it calls "retain" before returning a value, often combined with "autorelease"). "assign" (default) simply sets the pointer for situations that the caller & callee doesn't need to clean up (rarely w/o autorelease pools). You'd want a "retain" specifier whenever you're returning something that the caller understands that it owns the result... Things that your callee takes ownership over or are autoreleased. "copy" semantics are exactly like you'd expect. It's a byte-for-byte copy of the object (if it's written correctly).