关联对象 Associated Object
来源:互联网 发布:帽子淘宝网 编辑:程序博客网 时间:2024/04/27 20:37
需要在对象中存放某些信息,但是又无法从对象的所在类中继承一个子类,这时用到关联对象Associated Object。
例子 http://blog.csdn.net/lw223/article/details/21160767
管理关联对象
1 设置关联对象: void objc_setAssociatedObject (id object, void *key, id value, objc_AssociationPolicy policy)
2 获取关联对象中的value: id objc_getAssociatedObject (id object, void *key)
3 移除指定对象中所有关联对象: void objc_removeAssociatedOjbects (id object)
关联对象类型 objc_AssociationPolicy
/** * Policies related to associative references. * These are options to objc_setAssociatedObject() */enum { OBJC_ASSOCIATION_ASSIGN = 0, /**< Specifies a weak reference to the associated object. */ OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, /**< Specifies a strong reference to the associated object. * The association is not made atomically. */ OBJC_ASSOCIATION_COPY_NONATOMIC = 3, /**< Specifies that the associated object is copied. * The association is not made atomically. */ OBJC_ASSOCIATION_RETAIN = 01401, /**< Specifies a strong reference to the associated object. * The association is made atomically. */ OBJC_ASSOCIATION_COPY = 01403 /**< Specifies that the associated object is copied. * The association is made atomically. */};
0 0
- 关联对象 Associated Object
- OC 关联对象(Associated Object)
- iOS runtime 关联对象(Associated Object)
- iOS runtime 关联对象(Associated Object)
- Object-c Associated Object
- 深入学习Objective-C(二)理解 objc 关联对象 (Associated Objects)
- 深入学习Objective-C(二)理解 objc 关联对象 (Associated Objects)
- 深入学习Objective-C(二)理解 objc 关联对象 (Associated Objects)
- 高效开发iOS系列(runtime篇) -- 巧妙运用对象关联(Associated Objects)来设计alertview
- iOS associated object详解1
- iOS associated object详解2
- objc/runtime.h之Associated Objects ==关联
- myeclipse中.jsp文件关联的associated editors默认值修改
- 关联对象
- 关联对象
- 解决“no GUID has been associated with this object”错误
- 'IContextMenu' : no GUID has been associated with this object
- Object 对象
- C语言需要注意的基础知识点(兰亭风雨)
- 高性能MySQL之事务
- 多线程的那点儿事(之数据同步)
- Mali GPU OpenGL ES 应用性能优化--测试+定位+优化流程
- 卷一 内核源代码分析 第一章 linux内核对cortex A9多核处理器的支持 1.1 CPU的基本管理 图书试读版-请勿转载
- 关联对象 Associated Object
- ASP.NET面试题目整理1
- SVM(一) 问题的提出
- HTML5资源教程
- Android中的Thread、Looper、Handler之间的关系
- Android 中Message,MessageQueue,Looper,Handler详解+实例
- gdb调试
- linux netstat命令
- PAT Basic Level 1005. 继续(3n+1)猜想 (25)