属性的class属性是什么意思?

问题描述 投票:2回答:1

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

@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

class属性是什么意思?

objective-c class runtime
1个回答
1
投票

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

有关详细信息,请参阅this question and answer

© www.soinside.com 2019 - 2024. All rights reserved.