如何在运行时获取 Objective-C 属性 的声明属性?
How to get an Objective-C property's declared attributes at runtime?
假设 Objective-C 属性 声明如下:@property (nonatomic, strong) id foobar;
Objective-C 运行时提供 objc_property_attribute_t
应该 contain/encode 每个 属性 声明属性的值(nonatomic
,等等...)
但是,我无法在 Objective-C 运行时文档中找到 API 来访问 属性 的属性,即在我的示例中:nonatomic and strong
和 objc_property_t 是不透明类型。
因此我的问题是,如何在运行时获取 Objective-C 属性 的声明属性?
基于@Larme 的 link,API 在运行时获取 Objective-C 属性 属性是 property_getAttributes
在 <objc/runtime.h>
中定义的
假设 Objective-C 属性 声明如下:@property (nonatomic, strong) id foobar;
Objective-C 运行时提供 objc_property_attribute_t
应该 contain/encode 每个 属性 声明属性的值(nonatomic
,等等...)
但是,我无法在 Objective-C 运行时文档中找到 API 来访问 属性 的属性,即在我的示例中:nonatomic and strong
和 objc_property_t 是不透明类型。
因此我的问题是,如何在运行时获取 Objective-C 属性 的声明属性?
基于@Larme 的 link,API 在运行时获取 Objective-C 属性 属性是 property_getAttributes
在 <objc/runtime.h>
中定义的