NSControl isEnabled only available in OS X v10.0 through OS X v10.9

空扰寡人 提交于 2019-12-11 01:54:58

问题


Does anybody know why NSControl's isEnabled has been removed while setEnabled: is still working?


回答1:


In OS X 10.10 (and iOS 8), many of the getter/setter method pairs in Apple's frameworks were replaced by @property declarations. This both makes the header interface clearer and makes the import of those APIs into Swift more... well, Swifty.

// Before
- (BOOL)isEnabled;
- (void)setEnabled:(BOOL)enabled;

// After
@property(getter=isEnabled) BOOL enabled

The documentation hasn't been fully updated to reflect that, so it erroneously shows isEnabled as deprecated, even though the @property declaration means you can still do any of the following:

BOOL foo = [control isEnabled];
[control setEnabled:YES];
BOOL bar = control.enabled;
control.enabled = YES;


来源:https://stackoverflow.com/questions/28706592/nscontrol-isenabled-only-available-in-os-x-v10-0-through-os-x-v10-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!