我的 Objective-C 代码有问题。我正在尝试打印从“Person”类创建的对象的所有详细信息,但 NSLog 方法中没有显示名字和姓氏。它们被空格替换。
Person.h:http : //pastebin.com/mzWurkUL Person.m:http ://pastebin.com/JNSi39aw
这是我的主要源文件:
#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;
}