特性用来自动声明属性的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
本文详细解释了如何使用Objective-C的特性和类别来自动声明属性的setter和getter方法,包括如何在类中定义变量并为它们提供访问控制。

被折叠的 条评论
为什么被折叠?



