特性和类别

来源:互联网 发布:云计算工程师要求 编辑:程序博客网 时间:2024/05/22 05:15

特性用来自动声明属性的setter和gettter方法。

@interface Tire:NSObject{float rainHandling;       float snowHandloing;}@property float rainHandling;@property float snowHandling;@end@implementation Tire@synthesize rainHandling;@synthesize snowHandling;@end

类别则是向类中添加方法,注意,类别不能添加变量。

@interface Tire (Thing1)-(void) print;@end@implementation Tire (Thing1)- (void) print{     NSLog(@"good");}@end
原创粉丝点击