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'가 아니어야한다는 것을 알고 있습니다. 두 번째 스 니펫을 사용하여 클래스를 비유하여 질문을 명확하게 나타냅니다. 어쨌든 도움 주셔서 감사합니다. –