iOS dynamically added to an object category attributes associated with the object

- (NSString *)urlString {
    return objc_getAssociatedObject(self, "str");
}

- (void) setUrlString: (NSString *) the urlString {
    // attributes can be increased to an object during operation
    // associated objects
    
    objc_setAssociatedObject (Self, "STR", the urlString, OBJC_ASSOCIATION_COPY_NONATOMIC);
    
}

Published 368 original articles · won praise 22 · Views 200,000 +

Guess you like

Origin blog.csdn.net/BianHuanShiZhe/article/details/105009067