Objective-C for iPad, Where do you put IBOutlet? In instance variable decleration or @property decleration? Is there a difference at all?
views:
212answers:
5Both are valid, even if it's usually recommended to put it on a property.
The difference with a property is that it's available from the outside, and that getter/setter methods are used.
That also allows property qualifiers, like non-atomic and retain, usually set for the IBOutlets.
I do both, and synthesise it in the .m file. I'm not 100% that they're both essential, but it doesn't hurt.
IBOutlet can be a marker on ivars or a property declaration.
There is a slight difference. IBOutlet properties go through access methods whereas IBOutlet ivars are direct ivar access.
The major difference is that if the IBOutlet property is retained, you'll have to release it in -dealloc
whereas you typically need not do anything with an IBOutlet ivar. The upside of IBOutlet property is that you get all the useful features of properties.
mmalc (who is definitely a reputable source) says that the current best-practice is putting it on the @property declaration. He gives details (along with some cavets) in his answer to this quiestion