开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜