Associated Objects
2015-09-01 10:37
513 查看
Associated Objects—或者 Associative References,正如他们起初所被认识的那样—是Objective-C 2.0 runtime的特征,在OS X Snow Leopard(IOS 4)中被引进。具体指的就是
NSObject+AssociatedObject.m
@interface NSObject (AssociatedObject) @property (nonatomic, strong) id associatedObject; @end
NSObject+AssociatedObject.m
@implementation NSObject (AssociatedObject) @dynamic associatedObject; - (void)setAssociatedObject:(id)object { objc_setAssociatedObject(self, @selector(associatedObject), object, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - (id)associatedObject { return objc_getAssociatedObject(self, @selector(associatedObject)); }
相关文章推荐
- Objective-C入门 Xcode创建 HalloWorld
- Objective-C常用方法总结
- JSONObject遍历获取键值
- NSObject的load和initialize方法
- Annex B Rules for BER-TLV Data Objects
- equal方法在String类与Object类中的区别
- Selenium WebDriver 之 PageObjects 模式 by Example
- Objective-C 【电商APP应用代码-系统分析-详细注释-代码实现】
- Objective-C 【电商APP应用代码-系统分析-详细注释-代码实现】
- Objective-C 【@property 的参数问题】
- Objective-C 【@property 的参数问题】
- OC随机数方法
- [objective-c]_[performSelector的使用]
- objective-C编程 面向对象的编程基本概念
- [Objective-c]_[NSString的基本使用]
- OC中如何进行多文件开发?
- IOS之Objective-C学习笔记(六)
- 斯坦福大学iOS应用开发教程学习笔记(第三课) Objective-C
- NSMutableString可变字符串的定义及常用方法
- 关于JSONArray明明添加add JSONObject却为空