标签:style blog color io ar 文件 sp div on
#import <Foundation/Foundation.h> @interface ClassVirable : NSObject{ NSInteger year;//保护树形 } @property int age;//不用在实现文件中写@synthesize age就会有setAge:和age方法了 -(void)set:(NSInteger)i; @end
#import "ClassVirable.h" @implementation ClassVirable ///Property implementation must have its declaration in interface ‘ClassVirable‘ //@synthesize year; -(void)set:(NSInteger)i{ self.age = i; year = i; } @end
#import <Foundation/Foundation.h> #import "ClassVirable.h" int main(int argc, const char * argv[]) { @autoreleasepool { ClassVirable *c = [[ClassVirable alloc]init]; [c set:2]; [c setAge:20]; NSLog(@"%i",[c age]); NSLog(@"%i",c.age); //Instance variable ‘year‘ is protected // NSLog(@"%ld",(long)c->year); } return 0; }
标签:style blog color io ar 文件 sp div on
原文地址:http://www.cnblogs.com/ghgyj/p/4025659.html