@interface CSize : NSObject
-(id) initWithWidth: (int) width Height: (int) height;
@property int width, height;
@end
@implementation CSize
-(id) initWithWidth: (int) width Height: (int) height {
self = [super init];
if (self) {
self.width = width;
self.height = height;
}
return self;
}
@end
@interface CSize (CSizeExtension)
@property (readonly) int area;
@end
@implementation CSize (CSizeExtension)
- (int) area {
return self.width * self.height;
}
@end
CSize * size = [[CSize alloc] initWithWidth:4 Height:5];
int area = size.area;
//area is 20