oc_study17--property的简便方式

来源:互联网 发布:反编译软件 编辑:程序博客网 时间:2024/06/05 15:35
//成员变量age为@private//如果子类要访问age,必须在interface中声明int _age; 为@protected#import <Foundation/Foundation.h>@interface Dog : NSObject@property int age;@property int weight;@end@implementation Dog@endint main(void){    Dog * d = [Dog new];    [d setAge:5];    NSLog(@"age = %i", d.age);    return 0;}

0 0