开发者

Objective-C: `@synthesize fooBar;` vs. `@synthesize fooBar=_fooBar;` [duplicate]

This question already has answers here: 开发者_如何学编程 Closed 11 years ago.

Possible Duplicate:

Synthesized property and variable with underscore prefix: what does this mean?

I've seen both of these in code; what's the difference?

@synthesize fooBar;

@synthesize fooBar=_fooBar;


@synthesize fooBar; creates accessors for the property fooBar using an instance variable with the same name for storage, while the =_fooBar tells the compiler to use the instance variable named _fooBar as storage instead. You don't need to use the =... if you have your instance variables and properties identically named, and you do otherwise.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜