The @property
command in Objective-C 2.0 will automatically generate the instance variable for you if you have not done so. This is a shortcut introduced to limit the amount of repetitive code you have to write.
Only declare the iVar's if:
- Need to directly access them for some advanced reason (i.e. you want to manage the memory yourself)
- You want subclasses to be able to access the iVars (if you don't specify them at all, or specify them as
@private
, then subclasses will be forced to use your @synthesized
accessor methods.)
- You want your iVar to have a different name to the property itself, in which case use
@synthesize myProperty = myInstanceVariable_
NOTE: If you plan to run your code on older devices or compile it with older versions, you will need to declare iVars.