Swift协议合成
来源:互联网 发布:pdf阅读器有没有mac 编辑:程序博客网 时间:2024/06/05 10:08
import Foundationprotocol A { func show() -> Void}protocol B { func eat() -> Void}protocol C:A,B { func run() -> Void}class One: A{ func show() { print("A类的show方法") }}class oneMore: A { func show() { print("SSSSS") }}var o = One()var oMore = oneMore()var arr:[A] = [o,oMore]var ttt = arr[0] as! Oneprint(ttt)class Two: B { func eat() { print("吃") }}class Three: C { func show() { print("展示") } func eat() { print("吃") } func run() { print("跑") }}func test(obj:A&B) -> Void{}var one = One()var two = Two()var three = Three()test(obj: three)
阅读全文
0 0
- Swift协议合成
- Swift协议合成
- Swift协议合成(protocol composition)
- [Swift]协议
- Swift-协议
- Swift 协议
- Swift 协议
- swift 协议
- swift协议
- Swift协议
- Swift-协议
- swift 协议
- swift 协议
- Swift 协议
- swift 视频合成剪辑——swift学习(十)
- SBUS协议:SBUS解析与合成
- swift 协议和扩展
- swift入门- 协议
- 创建抽象类AA
- Okhttp网络请求
- GeekBand笔记-《STL与泛型编程 》 第四周
- Unity_与线程的关联
- non-local Means(非局部均值)降噪算法及快速算法原理与实现
- Swift协议合成
- Okhttp工具类
- Java:计算圆形和长方形的面积
- 线程的五大状态
- 10月25日 c语言 找到10000以内所有完数
- flask web开发-用户认证代码分析(三)
- Apache服务器的下载与安装
- Swift委托代理实现
- FastCgi与PHP-fpm之间是个什么样的关系