I’m little confuse because in some tutorials is just
in h
@property (readwrite,nonatomic) NSUInteger DirectProp;
in m
@synthesize DirectProp;
But in other is like this
in h
@interface MyClass : CCNode {
NSUInteger throuVarProp;
}
@property (readwrite,nonatomic) NSUInteger ThrouVarProp;
in m
@synthesize ThrouVarProp = throuVarProp;
Which way is the right way?
With a single argument:
The synthesized getter/setter methods are called the same as the instance variable used to store the value. This can get confusing. For example:
Are all valid.
With the additional
= ivar, you are able to name the instance variable (the convention being to use a leading underscore), which is a good idea, so you don’t get confused:As also mentioned, with newer runtimes you don’t need to declare the instance variable before use, which is also a bad idea and seems to be there to promote laziness. You will regret using this feature some day…