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進行類比,以使問題更清晰。無論如何,感謝您的幫助 –