* a member variable cannot be defined in a category and cannot define property
* if you define an attribute, you must override the getter&setter method
If the classification can achieve record attributes, function.
Need to use the 'runtime mechanism', is to develop OC language,
Three scenes are used in everyday development,
1. in classification, by adding attributes to the classification dynamics by association objects, the classification can be decoupled, and the frame.
can be developed
2., dynamic access to a list of attributes of the class, you can develop dictionary model transformation model framework.
3. exchange method, the address of dynamic exchange method, mainly used in take over system method,.
* dynamic association properties
1. the object
The key const void *key of the 2. attribute defines a constant (syntax equivalent to ID)
3. the value of the record attribute
4. references to associations
in OBJC_ASSOCIATION_ASSIGN ARC
in OBJC_ASSOCIATION_COPY ARC
Thread protection issues in OBJC_ASSOCIATION_COPY_NONATOMIC
in OBJC_ASSOCIATION_RETAIN_NONATOMIC ARC
The difference between weak and
The same point:
Neither strongly references.
The object referenced by weak, which automatically points to nil
once the reference count is 0
The object referenced by assign, once the reference count is 0, the object address is unchanged, so the wild pointer problem occurs under MRC. It is also a common bug
Objc_setAssociatedObject (<#id, object#>, <#const, void, *key#>, <#id, value#>, <#objc_AssociationPolicy, policy#>)
copyright notice: This article is original article for blogger. Without permission from blogger,.must not be reprinted