I've seen a lot of codes that do this:
@interface Test0 : NSObject {
@private int iVar;
}
@property (readwrite,assign) int iVar;
@end
and some other codes:
@interface Test0 : NSObject {
}
@property (readwrite,assign) int iVar;
@end
I know that you use the @synthesize iVar
to tell the compiler to generate the getter and the setter methods for the property iVar
.
My questions:
do we need to declare the @private int iVar;
instance variable?
What the advantage of doing so? What is the best practice of declaring instance variables vs property?
does the compiler link the instance variable with the property?
Thanks in advance.
See Question&Answers more detail:os