NSControl isEnabled仅在OS X v10.0到OS X v10.9中可用 [英] NSControl isEnabled only available in OS X v10.0 through OS X v10.9
问题描述
有人知道为什么NSControl的isEnabled已被移除而setEnabled:仍然工作?
Does anybody know why NSControl's isEnabled has been removed while setEnabled: is still working?
推荐答案
在OS X 10.10 iOS 8),Apple框架中的许多getter / setter方法对被 @property
声明替换。这两个使头部接口更清晰,并使那些API导入到Swift更多...好,Swifty。
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
文档没有完全更新以反映这一点,所以它错误地显示 isEnabled
已弃用,即使 @property
声明表示您仍然可以执行以下任何操作:
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;
这篇关于NSControl isEnabled仅在OS X v10.0到OS X v10.9中可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!