【问题标题】:What does the class attribute of property mean?属性的类属性是什么意思?
【发布时间】:2019-09-13 05:52:10
【问题描述】:

当我查看 Objective-C 的头文件 NSObject.h 时,我发现了一些类似以下的代码,但我找不到类作为属性的属性的含义。

@protocol NSSecureCoding <NSCoding>
@required
// This property must return YES on all classes that allow secure coding. Subclasses of classes that adopt NSSecureCoding and override initWithCoder: must also override this method and return YES.
// The Secure Coding Guide should be consulted when writing methods that decode data.
@property (class, readonly) BOOL supportsSecureCoding;
@end

类属性是什么意思?

【问题讨论】:

    标签: objective-c class runtime


    【解决方案1】:

    class 属性用于声明一个类属性。类属性由类的所有实例共享,这与 实例属性 不同,其中每个实例都有自己的副本。 Xcode 8 中引入的类属性,与实例属性不同,它们从不合成,程序员必须编写 getter 和 setter。

    更多详情请见this question and answer

    【讨论】:

    • 知道了。非常感谢。
    猜你喜欢
    • 2019-06-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2016-04-06
    • 2016-06-07
    • 1970-01-01
    • 2018-12-10
    相关资源
    最近更新 更多