Why tack a protocol of NSObject to a protocol implementation

前端 未结 5 428
野性不改
野性不改 2020-12-02 23:01

I have been seeing some code around that resembles the following:

@protocol MyProtocol 
// write some methods.
@end

Is ther

5条回答
  •  没有蜡笔的小新
    2020-12-02 23:27

    It's also very handy when you have protocols that have @optional methods (e.g. "modern" Objective-C 2.0 delegates often use this technique) If you don't include the NSObject protocol, you'll get warnings when you try to call respondsToSelector: on the object.

提交回复
热议问题