开发者

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

开发者 https://www.devze.com 2023-03-07 15:43 出处:网络
This question already has answers here: 开发者_如何学编程 Closed 11 years ago. Possible 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

精彩评论

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