@interface开发者_开发百科 first : <NSObject> {
NSString *myStr;
/**
I don't understand why declared this NSString *myStr.
Even if not declare NSString *myStr, this codes work well.
**/
}
@property (nonatomic, retain) NSString *myStr;
and Add @synthesize to first.m
Is it correct that I don't need to declare myStr as an instance variable if I always use the myStr property, i.e. self.myStr?
In the modern runtime (with a reasonably recent version of xcode, simulator etc.) it makes no difference because the compiler generates it for you.
Note that with the newest version of LLVM you don't even need the synthesize ;)
if you are using LLVM compiler then declaring instance variable who's property is declared is optional as the compiler creates automatically
精彩评论