I'm getting two errors having to do with incorrect Xcode grammar
(MemberPage *)initWithString: (NSString *) s {
self = [super init];
if ( self ) {
开发者_Go百科 //DO STUFF;
UserNAME.text = s;
}
}
return self;
I'm getting: use of undeclared identifier initWithString expected ; before : token
I've haven't been able to fix this after an hour so far, Thanks
There are a few tweaks that will solve this. See comments inline:
// Add '-' to show it is instance method
-(MemberPage *)initWithString: (NSString *) s {
self = [super init];
if ( self ) {
//DO STUFF;
UserNAME.text = s;
}
// Include this inside of the brace
return self;
}
As a note, by convention your instance variables should begin with a lower case letter and then use camel casing. So, UserNAME.text should be userName.text. The compiler expects this.
You are missing the -
token before your method signature and the return statement is outside the method body. Should look like:
- (MemberPage *)initWithString: (NSString *) s {
self = [super init];
if ( self ) {
//DO STUFF;
UserNAME.text = s;
}
return self;
}
You may also eventually have a problem on the UserNAME.text = s
line but without seeing your header file its hard to tell.
精彩评论