@protocol MyViewDelegate <NSObject>
- (void) didFinishProcessing:(MyView*)myView; //compiler stops here with error
@end
@interface MyView : MySuperclass {
id<MyViewDelegate> _delegate;
}
@property (nonatomic, retain) id<MyViewDelegate> delegate;
@end
When I try to compile I get " expected ')' before MyView开发者_C百科 ". Where is the error?
Before @protocol
add the line @class MyView
. At that point the compiler doesn't yet know about your MyView
class.
MyView
is not recognized by the compiler, which is why it expected a close paren before it. This is because the class is defined below the MyViewDelegate
protocol, so the compiler has not yet seen it. Add
@class MyView;
above the protocol declaration to fix it.
精彩评论