What's wrong with my Objective-C class?
Posted
by
zgillis
on Stack Overflow
See other posts from Stack Overflow
or by zgillis
Published on 2012-06-30T03:00:18Z
Indexed on
2012/06/30
3:15 UTC
Read the original article
Hit count: 458
I am having trouble with my Objective-C code. I am trying to print out all of the details of my object created from my "Person" class, but the first and last names are not coming through in the NSLog method. They are replaced by spaces.
Person.h: http://pastebin.com/mzWurkUL Person.m: http://pastebin.com/JNSi39aw
This is my main source file:
#import <Foundation/Foundation.h>
#import "Person.h"
int main (int argc, const char * argv[])
{
Person *bobby = [[Person alloc] init];
[bobby setFirstName:@"Bobby"];
[bobby setLastName:@"Flay"];
[bobby setAge:34];
[bobby setWeight:169];
NSLog(@"%s %s is %d years old and weighs %d pounds.",
[bobby first_name],
[bobby last_name],
[bobby age],
[bobby weight]);
return 0;
}
© Stack Overflow or respective owner