开发者

What is wrong with this code?

开发者 https://www.devze.com 2023-01-02 21:28 出处:网络
@protocol MyViewDelegate <NSObject> - (void) didFinishProcessing:(MyView*)myView; //compiler stops here with error
@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.

0

精彩评论

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