开发者

What is the use of properties alternative accessors names in Objective-C?

开发者 https://www.devze.com 2023-01-08 18:33 出处:网络
In Objective-C properties you can set alternative names for the 开发者_Python百科accessors. @property(setter=nameWrite:,getter=nameRead,copy) NSString *name;

In Objective-C properties you can set alternative names for the 开发者_Python百科accessors.

@property(setter=nameWrite:,getter=nameRead,copy) NSString *name;

I am thinking real hard but I don't know any situation I would ever do that. It is not KVC standard and I see no advantage at all. What is the use of it?


Mostly, it is used for BOOL properties:

@property(getter=isHidden) BOOL hidden;
@property(readonly, getter=isFinishedLaunching) BOOL finishedLaunching;

But, yeah, beyond that, it isn't used often at all (nor should it be).


It's seen all the time when you have a BOOL.

Ex:

@property(nonatomic,getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
0

精彩评论

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

关注公众号