结构(记录)

//In Objective-C there are no structures methods
@interface CPoint_3 : NSObject
@property int x, y;
-(void) moveRight: (int) right andDown: (int) down;
-(NSString *) toString;
@end

@implementation CPoint_3
-(NSString *) toString {
    return [NSString stringWithFormat:@"x = %i; y = %i"self.xself.y];
}

-(void) moveRight: (int) right andDown: (int) down {
    self.x += right;
    self.y += down;
}
@end

CPoint_3 *p1 = [CPoint_3 new];
p1.x = 1;
p1.y = 2;
NSString *str1 = [p1 toString];
//str1 is "x = 1; y = 2"

[p1 moveRight:5 andDown:-1];
NSString *str2 = [p1 toString];
//str2 is "x = 6; y = 1"