Object C self and super 关键字
来源:互联网 发布:百度云管家for mac 编辑:程序博客网 时间:2024/05/05 17:46
1.self 是从接收该者的开始查找方法.
2 super 则是从出现该super 关键字的类定义的父类开始查找方法.
Ie:
C继承 B ,B 继承 A .
三个类都定义了 printself 方法.
其中B 还定义了 testSupernadSelf 方法.
-(void)testSupernadSelf
{
[self printself];
}
C * t1=[[C alloc]init];
[t1 testSupernadSelf]; //首先是从t1 开始查找printself 方法,由于我们定义了C 的printself,所以会调用C printfSelf.
如果B的testSupernadSelf是这样定义.
-(void)testSupernadSelf
{
[super printself];
}
C * t2=[[C alloc]init];
[t2 testSupernadSelf]; //这时候就会从定义了super 关键字的类的父类开始查找. 那就是A,所以调用的是A printfSelf.而不是B printfSelf
- Object C self and super 关键字
- [object-c] self and super
- Object C---super&self
- Object-c self super
- object c关键字self 跟super 的区别
- Objective-C - self关键字和super关键字
- 【Object-C】继承,super关键字
- Object-C学习(二):关键字self、super、static的简单理解
- object-c中的self和super
- self 和 super 详解 -Object-C
- 关于object-c中的super与self
- Object-C self = [super init]
- Objective-C 中的关键字 self 和 super
- Objective-C关键字self和super详解
- objective-c中的self和super关键字
- Objective-C self和super关键字解析
- Object-C中 Self 关键字的理解
- 关键字”self”和”super”
- xmlschema
- 请定义一个宏,比较两个数a、b的大小,不能使用大于、小于、if语句。
- from表单序列化&JQuery源代码中两个小扣好的意义&StringUtils的用法
- mount error 12 = Cannot allocate memory
- 设计模式-单例
- Object C self and super 关键字
- struts2 jsp File "/struts-tags" not found
- 简易密码输入自定义控件示例 含自定义事件 可在调用窗口事件视图中看到事件名
- 详细的SQL事务
- FFmpeg和h.264是什么关系
- struts2和jquery_validator简单使用
- hdu 1698 Just a Hook
- serializer
- 图论;单源最短路径;拓扑排序+松弛(有向无回路);Bellman-Ford(回路,负权回路);Dijkstra(无负权,可回路);可以用最小堆实现算法的优化;