Reputation: 16663
In a method in my protocol 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
Upvotes: 1
Views: 433
Reputation: 170859
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
Upvotes: 4