开发者

How to init NSObject<protocol> pointer so it responds to delegate SEL?

I have such thing in my class definition:

NSObject<SomeProtocol> *dataDelegate;

I have custom -(id)init method i开发者_JS百科n which I should init this NSObject. How do I do it if I want it to respond selectors from SomeProtocol?


If you have a class declared to implement SomeProtocol, then you'd just do:

@interface SomeClass:NSObject <SomeProtocol>
.... etc ....

And in the implementation:

dataDelegate = [SomeClass new]; // or alloc/init


You just need to create an instance of a class that implements the protocol.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜