我有一个简单的问题要问。
我有一个ViewController,它使用UITableView来显示事物列表。 UITableView委托是这个ViewController(使用dataSource = self等)。
在所有教程中,我知道我需要使用以下命令在接口中定义委托类:
@interface Class : SuperClass <ClassNameDelegate>但是,所有代码都可以正常工作,而无需声明并仅实现方法。 例如:
@interface Class: SuperClass是个bug吗? 我还是需要申报吗?
谢谢。
毛罗
I have a simple question to ask.
I have a ViewController that use a UITableView to show a list of things. The UITableView delegates are the this ViewController (using dataSource = self, etc..)
In all tutorials i know that i need to define the delegate class in the interface using:
@interface Class : SuperClass <ClassNameDelegate>But all the code works good also without declaring this and implementing only the methods. For example:
@interface Class: SuperClassIs a bug? I need to declare it anyways?
Thank you.
Mauro
最满意答案
在通常情况下,我们使用performSelector来调用委托方法,如下所示:
[(NSObject *)_delegate performSelector:@selector(storeFeedbackViewControllerWasDismissed)];一切正常,因为这个委托有这个方法。
但最好指出该类符合协议,因为XCode可以警告您实现您可能错过的所需委托方法。
In common case we use performSelector to call delegate methods like this:
[(NSObject *)_delegate performSelector:@selector(storeFeedbackViewControllerWasDismissed)];and everything works because this delegate have got this method.
But it's better to point that class conforms protocol because XCode can warn you to implement required delegate methods that you can miss.
更多推荐
发布评论