7
我有两个协议相互通信。它们在相同的文件中定义。声明协议,如@class
@protocol Protocol1 <NSObject>
-(void)setProtocolDelegate:(id<Protocol2>)delegate;
@end
@protocol Protocol2 <NSObject>
-(void)protocol:(UIViewController<Protocol1>*)anObject chosenElementAtIndex:(NSInteger)aIndex;
@end
如何声明一个空的协议Protocol2
只是为了让知道它以后宣布编译器?
如果Protocol2
是我以前写的@class Protocol2;
。
@class Protocol2;
@protocol Protocol1 <NSObject>
-(void)setProtocolDelegate:(Protocol2*)delegate;
@end
@interface Protocol2 <NSObject>
-(void)protocol:(UIViewController<Protocol1>*)anObject chosenElementAtIndex:(NSInteger)aIndex;
@end
协议的类似结构是什么?
我知道它不应该是'@ class'。我用第二个片段与Classes进行类比,以使问题更清晰。无论如何,感谢您的帮助 –