oc - 6 description NSLog(扩展) SEL
来源:互联网 发布:英语六级怎么准备 知乎 编辑:程序博客网 时间:2024/05/22 08:09
-description
输出结果为
1.会调用实例对象p的-description方法
2.拿到-description方法的返回值(NSString *)显示到屏幕上
一般情况下我们会重写description方法.
+description
1.会调用类对象 Person的+description方法输出结果.
2.+description方法的返回值(NSString *)显示到屏幕上.
例如Class c = [Person class];
NSLog(@"%@" , c);
默认会输出"Person".
NSLog(扩展)
结果是
SEL 给方法的一个包装
1. 方法的存储位置
- 每个类的方法列表都存储在类对象中
- 每个方法都有一个与之对应的SEL类型的对象
- 根据一个SEL对象就可以找到方法的地址,进而调用方法
1. SEL对象的创建
SEL s = @selector(test);
SEL s2 = NSSelectorFromString(@"test"); NSSelectorFromString:把字符串数据传入,转成sel类型数据.
上面等价于 SEL s =@selector(tesr2);
[p performSelector s];
performSelector:调用p对象里的SEL类型数据方法 s.
SEL作用
1.把test2包装成SEL类型的数据.
2.根据SEL数据找到对应的方法地址
3.根据方法地址调用对应的方法.
如果要传入数据,用下面方法.
_cmd 是SEL类型数据 代表当前方法的SEL类型数据
0 0
- oc - 6 description NSLog(扩展) SEL
- oc笔记<6>description方法与NSLog
- 黑马程序员-description,NSLog补充以及SEL
- 黑马程序员----objective-C description NSLog SEL
- OC中description和SEL
- OC中的description和sel
- OC语言SEL和description
- OC基础—description方法、SEL类型
- OC语言description方法和sel
- OC中description方法和sel
- OC语言description方法和sel
- OC语言description方法和sel
- OC语言12-description方法和sel
- 黑马程序员-- ID init(构造方法) Class NSLog description SEL
- 黑马程序员 _8 OC基础 id description sel的使用
- OC基础-类的本质+description+SEL
- 13、黑马程序员-OC语言description方法和sel
- OC核心语法(4)description方法和SEL
- ZendStudio试用期到了-linux下
- CGridListCtrlEx
- 海尔U+的启示:让用户对智能家居拥有“话语权”
- linux下Makefile学习之二(书写规则)
- draw2d,toolbar布局让单元格高度相等方法
- oc - 6 description NSLog(扩展) SEL
- 北航校赛 这样还真是令人高兴啊
- Unity键盘事件
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
- Base64 encoder and decoder for ActionScript 3
- java socket编程
- HDU 4322 Candy 最大费用流
- 【Leetcode】Find Peak Element
- Unity数据持久化