.h
{
NSString *_name;
int _age;
}
-(void)setName:(NSString *)namea;
-(NSString *)namea;
-(void)setPrice:(int)pricea;
-(int)pricea;
.m
-(void)setName:(NSString *)namea{
_name=namea;
}
-(NSString *)namea{
return _name;
}
-(void)setPrice:(int)pricea{
_age=pricea;
}
-(int)pricea{
return _age;
}
main.m
Phone *li=[[Phone alloc]init];
li.name=@"李莉";
li.price=18;
NSLog(@"%@%d",li.namea,li.pricea);
Phone *wang=[[Phone alloc]init];
wang.name=@"1234567";
wang.price=18;
NSLog(@"%@%d",wang.namea,wang
.pricea);
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}