i'm receiving error "cannot find protocol declaration checkmarkdelegate" in contentaviewcontroller.h. why this?
quiztableviewcontroller.h
quiztableviewcontroller.mcode:#import <uikit/uikit.h> #import "contentaviewcontroller.h" @protocol checkmarkdelegate <nsobject> @required - (void) processsuccessful: (bool)success; @end @interface quiztableviewcontroller : uitableviewcontroller { id <checkmarkdelegate> delegate; } @property (retain) id delegate; @end
contentaviewcontroller.hcode:#import "quiztableviewcontroller.h" @implementation quiztableviewcontroller @synthesize delegate; - (void) processcomplete { [self.delegate processsuccessful:yes]; } - (void)viewdidload { [super viewdidload]; [self.tableview reloaddata]; }
contentaviewcontroller.mcode:#import <uikit/uikit.h> #import "quiztableviewcontroller.h" @interface contentaviewcontroller : uiviewcontroller <checkmarkdelegate> @end
code:#import "contentaviewcontroller.h" @implementation contentaviewcontroller - (void) processsuccessful: (bool) success { nslog(@"process succesful"); } - (ibaction)ok:(id)sender { if ([answeraval.text isequaltostring:@"correct!"]) { [self processsuccessful:yes]; } else { [self dismissmodalviewcontrolleranimated:yes]; } }
because quiztableviewcontroller.h importing contentaviewcontroller.h.
think happens when compiler comes compiling quiztableviewcontroller.m.
first thing encounters #import "quiztableviewcontroller.h". basically, line replaced contents of quiztableviewcontroller.h , compilation continues first line of quiztableviewcontroller.h.
second thing happens uikit/kit.h imported in same way.
third thing happens #import "contentaviewcontroller.h" again in same way.
we're @ first line of "contentaviewcontroller.h. #import <uikit/uikit.h> nothing because uikit/uikit.h has been imported.
#import "quiztableviewcontroller.h" ignored because quiztableviewcontroller.h has (is being) imported.
compiler @interface contentaviewcontroller line in quiztableviewcontroller.h references checkmarkdelegate, can see compiler has never seen @protocol checkmarkdelegate @ point. complains.
you've posted, there's not need quiztableviewcontroller.h import contentaviewcontroller.h, take out.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment