2つのプロトコルが相互に通信しています。それらは同じファイルで定義されています。
@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
プロトコルの同様の構造は何ですか?