id objc_getAssociatedObject(id object, const void *key)
void objc_setAssociatedObject(id object, const void *key, id value, objc_AssociationPolicy policy)
void objc_removeAssociatedObjects(id object)
複製代碼
- (void)willChangeValueForKey:(NSString *)key;
...
- (void)didChangeValueForKey:(NSString *)key;
複製代碼
- (id)valueForKey:(NSString *)key;
- (void)setValue:(id)value forKey:(NSString *)key;
複製代碼
MRC下重寫retain修飾變量的setter方法編程
@property (nonatomic, retain) id obj;
- (void)setObj:(id)obj {
if (_obj != obj) {
[_obj release];
_obj = [obj retain];
}
}
複製代碼