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)
}
即Class Test!协议init以及测试类Swift协议代表返回零
class calling:testDelegate{
override func viewDidLoad() {
//blah blah
}
func func open(channel: String, vc: UIViewController){
print("calling")
}
这是调用类。
我想在调用类中调用open func,但它根本不调用, 在测试类中甚至打印(“hello”)没有调用它,因此保持返回nil,因此也不会调用调用函数。
您是否在呼叫控制器中设置了测试控制器的代表? –
@NiravD我设置类调用:testDelegate像这样 – john
这是用来实现协议我问的是你在哪里设置委托? –