[TwistedFate]category Extensxion protocol
来源:互联网 发布:mysql 登录失败 锁定 编辑:程序博客网 时间:2024/06/01 14:33
类目category
类目特点:
可以给看不到实现的系统类添加方法 并且添加的方法 使用系统类的对象 或者 类名 直接就可以调用的
切记:
1.只能添加方法 不能添加实例变量
2.类目中添加的方法相当于直接添加到系统类中 是可以被继承的
注意:在实际编程中,应注意积累,对以后的编程能提供很大的便利
延展Extension
或者
@implementation Function
// 私有方法的实现 也写在@implementation中
- (void)sayHi{
NSLog(@”hah “);
}
@end
协议protocol
使用协议代理的步骤
1.先创建协议
2.实现协议中的方法
3.设置代理(添加代理对象为实例变量) –(在需要代理的类里 声明实例变量)
4.添加设置代理对象(必须是遵守协议的对象)的方法(set方法)
5.让代理去调用协议中的方法
6.从main创建对象 设置代理对象
如何遵守协议:
用尖括号 来表示遵守的协议
协议中声明的是协议方法
如果没有明确要求,协议中的方法都要实现
0 0
- [TwistedFate]category Extensxion protocol
- Category / Extensions / Protocol /Informal Protocol
- Category vs Protocol
- Mac/iPhone Category & Protocol
- Category Protocol 使用场合
- Category Protocol 使用场合
- 继承,Protocol,Category
- Category、Extension、Protocol
- Category Extension protocol 总结
- category、block、protocol、SEL
- 分类(category)、协议(protocol)
- 8、category、extension、protocol
- Category protocol delegate
- Category、Protocol、Extension
- Category和protocol区别
- object-c category 和 protocol
- Category和protocol的区别
- iOS的category和protocol
- 开源游戏框架
- 归并排序
- poj 1147 Binary codes bwt压缩算法
- Ubuntu下最简单的安装Oracle Java的方法(使用PPA)
- Installshield判断系统版本
- [TwistedFate]category Extensxion protocol
- Hive1.2.1--hwi配置
- 【jQuery】 ui effects
- Android开发主要组件
- 一、基于单文档 添加动态菜单
- AIDL介绍和实例讲解
- Scanner类
- Python staticmethod and classmethod
- MySql源码编译时支持的参数