protocol testDelegate: class {
func open(channel: String, vc: UIViewController)
}
class test: UIViewController{
weak var delegate: testDelegate?
}
override func viewDidLoad() {
super.viewDidLoad()
if self.delegate != nil {
print("hello")
self.delegate?.openGroupChannel(channel: channel!, vc: self)
}
Run Code Online (Sandbox Code Playgroud)
那是课堂测试!测试类中的协议初始化也是如此
class calling:testDelegate{
override func viewDidLoad() {
//blah blah
}
func func open(channel: String, vc: UIViewController){
print("calling")
}
Run Code Online (Sandbox Code Playgroud)
这是调用类。
我想在调用类中调用 open func 但它根本不调用,甚至测试类中的 print("hello") 也没有调用它,它保持返回 nil 因此也不会调用调用函数。