简体   繁体   English

如何实现自定义协议

[英]How to implement a custom protocol

In this part of my code I get a warning message saying it doesn't implement the custom protocol I made. 在代码的这一部分中,我收到一条警告消息,提示它未实现我制定的自定义协议。

detailViewController.delegate = self;

How do I implement the protocol? 如何实施协议?

Then when I run the program it crashes saying 然后,当我运行程序时,它崩溃了,

'-[DetailViewController setDelegate:]: unrecognized selector sent to instance 0x6a1c450' '-[DetailViewController setDelegate:]:无法识别的选择器已发送到实例0x6a1c450'

Declare your class like this: 像这样声明您的课程:

@interface DetailViewController : UIViewController <MyProtocol> {
    // Class stuff
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM