ios developer tiny share-20160929
来源:互联网 发布:少儿编程教育培训 编辑:程序博客网 时间:2024/06/10 22:32
今天讲Objective-C的protocol的继承。
Protocols Inherit from Other Protocols
In the same way that an Objective-C class can inherit from a superclass, you can also specify that one protocol conforms to another.
As an example, it’s best practice to define your protocols to conform to the NSObject protocol (some of the NSObject behavior is split from its class interface into a separate protocol; the NSObject class adopts the NSObject protocol).
By indicating that your own protocol conforms to the NSObject protocol, you’re indicating that any object that adopts the custom protocol will also provide implementations for each of the NSObject protocol methods. Because you’re presumably using some subclass of NSObject, you don’t need to worry about providing your own implementations for these NSObject methods. The protocol adoption is useful, however, for situations like that described above.
To specify that one protocol conforms to another, you provide the name of the other protocol in angle brackets, like this:
@protocol MyProtocol <NSObject>...@end
In this example, any object that adopts MyProtocol also effectively adopts all the methods declared in the NSObject protocol.
- ios developer tiny share-20160929
- ios developer tiny share-20160628
- ios developer tiny share-20160629
- ios developer tiny share-20160630
- ios developer tiny share-20160701
- ios developer tiny share-20160704
- ios developer tiny share-20160705
- ios developer tiny share-20160706
- ios developer tiny share-20160707
- ios developer tiny share-20160708
- ios developer tiny share-20160711
- ios developer tiny share-20160712
- ios developer tiny share-20160713
- ios developer tiny share-20160714
- ios developer tiny share-20160715
- ios developer tiny share-20160718
- ios developer tiny share-20160719
- ios developer tiny share-20160720
- Java资源
- 使用Android Studio 过程中遇到的问题
- RHEL7虚拟机与主机设置共享文件
- 左右无缝滚动
- Effective C++ 第3条:尽可能使用const
- ios developer tiny share-20160929
- DrawRect
- Oracle replace
- MyBatis逆向工程
- iOS迭代版本 (转)
- 单例模式
- 第一章:我的java学习之路
- ERROR 1366 (HY000): Incorrect string value: '\xC2\xEC\xD2\xCF\xD2\xB2...' for column 'title' at row
- Requestlayout,onlayout,onDraw,DrawChild区别与联系