您的位置:首页 > 其它

Protocol 协议相关定义和操作方法

2014-12-19 13:48 162 查看
协议:

生活中:就业协议,劳务协议

计算机中:http协议,udp协议,mail,telnet远程登录协议,ftp协议,usb1.0协议,usb2.0协议,usb3.0协议,spi协议,i2c协议

oc ios协议:方法的接口列表

//继承:子类继承父类的是变量跟方法,子类当中不需要实现继承过来的方法

//协议:能够被多个类共享方法接口,每个类在使用相关的方法的时候,需要自己去实现该方法,

每个类中的实现可能不同,但是方法的 的
*******************************************************

1.定制协议

//@protocol :定制协议

//Coder : 协议名

@protocol Coder <NSObject> //继承基协议

- (void)writeCode;

- (void)report;

- (void)debug;

@end

*******************************************************

2.遵守协议

@interface QFStudent : NSObject <Coder>

*******************************************************

3.实现协议

@implementation QFStudent

- (void)writeCode

{

NSLog(@“sdflaj");

}

- (void)report

{

NSLog(@“sdflaj");

}

- (void)debug

{

NSLog(@“sdflaj");

}

*******************************************************
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: