在我的协议中的方法中,我需要在下面的接口中定义的类,我该如何解决这个问题;
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
// methods
@end
我收到了错误;
':'标记之前的预期标识符
答案 0 :(得分:4)
使用前瞻声明:
或者:
@class MyObject;
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
@end
或
@protocol MyDelegate;
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
@end
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end