objective c - Error: No visible @interface for 'XYZPerson' declares the selector 'saySomething' -


searched through several threads cannot find answer.

i new objective-c , going through briefer @ apple development , experimented , keep getting error: no visible @interface 'xyzperson' declares selector 'saysomething'

the console program has added class called xyzperson. here .h , .m files:

this xyzperson.h file:

#import <foundation/foundation.h>  @interface xyzperson : nsobject  @property (readonly) nsstring *firstname; @property (readonly) nsstring *lastname; @property (readonly) nsdate *dateofbirth;  - (void)sayhello; - (void)saybooboo; - (void)saysomething;  + (id)person;  @end 

this xyzperson.m file:

#import "xyzperson.h"  @implementation xyzperson  - (void)sayhello {     [self saysomething:@"say hello, world!"]; }  - (void)saybooboo {     [self saysomething:@"say booboo, world!"]; }   - (void)saysomething:(nsstring *)greeting {     nslog(@"%@", greeting); } @end 

here code in main():

#import <foundation/foundation.h> #import "xyzperson.h"  int main(int argc, const char * argv[]) {      @autoreleasepool {          // insert code here...         nslog(@"hello, world main!");          xyzperson *aperson = [[xyzperson alloc] init];          [aperson sayhello];         [aperson saybooboo];          [aperson saysomething:@"something"];      }     return 0; } 

this causes build failed. if delete line in main() " [aperson saysomething:@"something"];"

then program run following output:

013-05-14 15:38:04.102 xyzperson[2303:303] hello, world main!  2013-05-14 15:38:04.105 xyzperson[2303:303] hello, world!  2013-05-14 15:38:04.106 xyzperson[2303:303] booboo, world! 

just cannot figure out why can call [aperson sayhello] , [aperson saybooboo] in main() [aperson saysomething:@"something."] causes problem.

as pointed out in comments, exact same question has been answered give quick answer, .h has method - (void)saysomething; while .m requests input parameter (an nsstring) need change saysomething in .h this:

- (void)saysomething:(nsstring *)greeting 

which exact same signature using in .m.

because have limited activity on stackoverflow want recommend doing bit of research before posting questions. sure did benefits if thorough in search before posting questions on here.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -