objective c - I don't know what's missing in my code. It says "Expected identifier or '('" -
i don't know what's missing in code. says "expected identifier or '('" please help. these lines have error.
#import "viewcontroller.m" { - (bool)textfieldshouldreturn:(uitextfield *)textfield; nslog(self.mytextfield.text) [self.mytextfield resignfirstresponder]; return yes; } @end
first, #import
header (.h) files, not source (.m) files. so, first line should be:
#import "viewcontroller.h"
normally, such import near top of source file. method definition follows has inside of @implementation
, appear between imports , method definitions. so, should add line like:
@implementation viewcontroller
the @end
@ bottom of code snippet corresponds @implementation
.
then, seem have swapped method signature line , line opening brace method. have:
{ - (bool)textfieldshouldreturn:(uitextfield *)textfield;
when should have:
- (bool)textfieldshouldreturn:(uitextfield *)textfield; {
you don't need semicolon (;
) on end of line, it's harmless.
finally, statement call nslog()
incomplete because needs terminated semicolon:
nslog(self.mytextfield.text);
perhaps accidentally typed semicolon meant line on line above, explain extraneous semicolon there.
Comments
Post a Comment