ios - No @interface for CalculatorViewController -
this error appears both 'double result' , 'if' @ bottom.
not sure why happening, itunes u lecture , far can tell scanning multiple times same.
the problem
no visible @interface 'calculatorviewcontroller' declares selector 'enterpressed'
#import "calculatorviewcontroller.h" #import "calculatorbrain.h" @interface calculatorviewcontroller() @property (nonatomic) bool userisinthemiddleofenteringanumber; @property (nonatomic, strong) calculatorbrain *brain; @end @implementation calculatorviewcontroller @synthesize display = _display; @synthesize userisinthemiddleofenteringanumber = _userisinthemiddleofenteringanumber; @synthesize brain = _brain; - (calculatorbrain *)brain { if(!_brain) _brain = [[calculatorbrain alloc] init]; return _brain; } - (ibaction)digitpressed:(uibutton *)sender { nsstring *digit = sender.currenttitle; if(self.userisinthemiddleofenteringanumber){ self.display.text = [self.display.text stringbyappendingstring:digit]; } else { self.display.text = digit; self.userisinthemiddleofenteringanumber = yes; } } - (ibaction)enterpressed:(id)sender { [self.brain pushoperand:[self.display.text doublevalue]]; self.userisinthemiddleofenteringanumber = no; } - (ibaction)operationpressed:(uibutton *)sender { if(self.userisinthemiddleofenteringanumber) [self enterpressed]; double result = [self.brain performoperand:sender.currenttitle]; nsstring *resultstring = [nsstring stringwithformat:@"%g", result]; self.display.text = resultstring; } @end
you've got:
if(self.userisinthemiddleofenteringanumber) [self enterpressed]; change to:
if(self.userisinthemiddleofenteringanumber) [self enterpressed:self]; you're getting error because you've forgot parameter (id)sender declared in enterpressed.
- (ibaction)enterpressed:(id)sender
Comments
Post a Comment