In a method in my protoco开发者_运维百科l I require the class defined in the interface below, how do I solve this;
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
// methods
@end
I get the error;
Expected identifier before ':' token
Use forward declaration:
either:
@class MyObject;
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
@end
or
@protocol MyDelegate;
@interface MyObject : NSObject
{
id<MyDelegate> delegate;
}
@end
@protocol MyDelegate
-(void) somethingFinished:(MyObject*)object anyOtherData:(NSData*)data;
@end
精彩评论