Category - runtime

@porperty 做了以下三件事

1.生成实例变量 _property

2.生成 getter 方法 - property

3.生成 setter 方法 - setProperty


但是在分类(Category)中,@porperty不能主动生成实例变量和setter,getter方法,需要手动实现。【Associated Object -关联对象】

- (NSMutableArray*)attributeStrings

{

    return objc_getAssociatedObject(self, _cmd);

}

- (void)setAttributeStrings:(NSMutableArray*)attributeStrings

{

    objc_setAssociatedObject(self, @selector(attributeStrings), attributeStrings, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容