开发者

require class in protocol

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜