| 
 
| OC中get、set方法,我用set方法把名字设成中文,却总是显示不了,这个是什么原因?? #import <Foundation/Foundation.h>
 
 @interface Person :NSObject{
 char* _name;
 int _age;
 }
 //名字
 -(void)setName:(char*)name;
 -(char*)getName;
 //年龄
 -(void)setAge:(int)age;
 -(int)getAge;
 
 @end
 @implementation Person
 //名字
 -(void)setName:(char*)name{
 _name =name;
 }
 -(char*)getName{
 NSLog(@"姓名:%s",self->_name);
 return _name;
 }
 //年龄
 -(void)setAge:(int)age{
 _age=age;
 }
 -(int)getAge{
 NSLog(@"年龄:%d",self->_age);
 return _age;
 }
 
 @end
 int main(int argc, const char * argv[]) {
 Person* p1=[Person new];
 [p1 setName:"八神"];
 [p1 getName];
 [p1 setAge:10];
 [p1 getAge];
 return 0;
 }
 这个是什么原因??求指教
 | 
 |