Skip to content

Instantly share code, notes, and snippets.

@edwardean
Last active July 21, 2017 02:55
Show Gist options
  • Save edwardean/6ed1cfe52132507a0b6e09b2c00d3555 to your computer and use it in GitHub Desktop.
Save edwardean/6ed1cfe52132507a0b6e09b2c00d3555 to your computer and use it in GitHub Desktop.
class_copyPropertyList
int outCount;
objc_property_t *properties = class_copyPropertyList([MyObject class], &outCount);
for(i = 0; i < outCount; i++) {
objc_property_t property = properties[i];
const char *c_attributes = property_getAttributes(property);
printf("%s", c_attributes);
}
free(properties);
属性类型 name值:T value:变化
编码类型 name值:C(copy) &(strong) W(weak) 空(assign) 等 value:无
非/原子性 name值:空(atomic) N(Nonatomic) value:无
变量名称 name值:V value:变化
R
The property is read-only (readonly).
C
The property is a copy of the value last assigned (copy).
&
The property is a reference to the value last assigned (retain).
N
The property is non-atomic (nonatomic).
G<name>
The property defines a custom getter selector name. The name follows the G (for example, GcustomGetter,).
S<name>
The property defines a custom setter selector name. The name follows the S (for example, ScustomSetter:,).
D
The property is dynamic (@dynamic).
W
The property is a weak reference (__weak).
P
The property is eligible for garbage collection.
t<encoding>
Specifies the type using old-style encoding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment