Value of type NSObject -> () -> **ViewController does not conform to specified type ***Delegate

核能气质少年 提交于 2019-12-25 17:07:11

问题


I am receiving the error below:

My protocol looks like this:

protocol RecorderDelegate {

  func finishedRecordingWithUrl(URL: NSURL)
}

Can someone explain why self is NOT conforming to the protocol when it appears that it is?


回答1:


At the time you are setting self as reference, self does not exist. Try to set it later, let say viewDidLoad or make it lazy.

Btw make the reference on delegate weak, otherwise you are creating reference cycle and your view controller instance is never going to dealloc and will create memory leak.



来源:https://stackoverflow.com/questions/38961146/value-of-type-nsobject-viewcontroller-does-not-conform-to-specified-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!