看完docs关于这个我发现
In Swift, as in Objective-C, protocol conformance is global—it is not possible for a type to conform to a protocol in two different ways within the same program.
那么这里私有(private)前缀的作用是什么
private protocol PartyFormViewControllerDelegate: class {
func partyFormViewController(controller: PartyFormViewController, cancelButtonPressed button: UIBarButtonItem)
}
class PartyFormViewController: GenericViewController {
//...
}
最佳答案
在 Swift 中,private
表示:在当前源文件中可见。
私有(private) Type
可以符合私有(private)协议(protocol),看这里:
private protocol Animal { }
private class Dog: Animal { }
class Zoo {
private var animals = [Animal]()
var count : Int { return animals.count }
}
在这里,Animal 和 Dog 仅在当前文件中可见。但是,它们被 Zoo
使用,它具有内部可见性并将动物的数量公开给整个模块。
关于ios - 私有(private)快速协议(protocol)是否可能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38673619/