开发者

Synthesize in Objective C [duplicate]

开发者 https://www.devze.com 2023-02-14 11:31 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: @property @synthesize 开发者_如何学运维
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

@property @synthesize

开发者_如何学运维

Explain the working or purpose of synthesize


Basically, @synthesize automatically generates the getters and setters based on the @property declaration.


synthesize used with property.When you declair a property in .h file then you need to synthesize that in .m file.

@synthesize creates getter and setter for your property.If you do not synthesize the property then you can use property.(it gives crash).

var=self.yourProperty (calling getter). simmiler to var=[self getYourProperty];

self.yourProperty=var (calling setter). simmiler to [self setYourProperty:var];

without synthesize you cant use the setter and getter.

0

精彩评论

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

关注公众号