Reputation: 5281
I have a class like this..
#import "MyObjectAddView.h"
#import "MyAppDelegate.h"
#define myAppDelegate (MyAppDelegate *) [[UIApplication sharedApplication] delegate]
@class MyObjectAddView;
@interface AccountViewController : UIViewController <UIScrollViewDelegate, MyObjectAddViewDelegate, UIImagePickerControllerDelegate> {
MyObjectAddView *myAddView;
.....
}
@property (nonatomic, retain) IBOutlet MyObjectAddView *myAddView;
- (id) initWithSettings:(SettingsObject *)settings;
@end
WHY is it suddenly telling me that it Cannot find protocol declaration for 'MyObjectAddViewDelegate' when I'm clearly importing and including the @class for where the protocol is defined? Here how MyObjectAddView setup:
#import <UIKit/UIKit.h>
#import "MyAppDelegate.h"
#define myAppDelegate (MyAppDelegate *) [[UIApplication sharedApplication] delegate]
@protocol MyObjectAddViewDelegate;
@interface MyObjectAddView : UIView <UITextFieldDelegate> {
@private
id <MyObjectAddViewDelegate> delegate;
....
@public
.....
}
@property(nonatomic, assign) id <MyObjectAddViewDelegate> delegate;
.....
@end
@protocol MyObjectAddViewDelegate <NSObject>
// expense == nil on cancel
- (void)myObjectAddViewDidFinish:(MyObjectAddView *)addView;
@end
Everything seems perfectly setup and I don't see any circular imports ?! Any suggestions why it might not be seeing the protocol definition in MyObjectAddView?
Thanks.
Upvotes: 6
Views: 12548
Reputation: 6756
Synthesizing the discussion: another solution is to check for cyclical imports between the delegate implementation and protocol declaration. This solved my issue.
Upvotes: 6
Reputation: 57179
You do not need a forward reference to a class after you have imported the header for that class. Only time you do a forward reference is if you plan on including the header inside of the implementation file. Remove @class MyObjectAddView
and if that fixes it let me know if not I may have another solution for you.
Upvotes: 8