我的protocol.swift文件
protocol child1Protocol {
static var label1: String { get }
}
protocol child2Protocol {
static var label2: String { get }
}
// Not sure if this is correct syntax, but my idea is to have one parent Protocol
protocol parentProtocol: child1Protocol,child2Protocol {
}
在我的控制器中我想这样使用
Class exampleController: parentProtocol {
print(label1)
print(label2)
}
而不是
Class exampleController: child1Protocol, child2Protocol {
print(label1)
print(label2)
}
成功了
protocol child1Protocol {
var label1: String { get }
}
protocol child2Protocol {
var label2: String { get }
}
// this is correct syntax
protocol parentProtocol: child1Protocol,child2Protocol {
}
Class exampleController: parentProtocol {
print(label1)
print(label2)
}