读书人

obj c car 各类已拆分(此程序不符合内

发布时间: 2012-09-09 09:27:54 作者: rapoo

obj c car 各类已拆分(此程序不符合内存管理规则)

xcode4.2

未了把代码看清楚,拆分

main.m:

////  Car.m//  carDemo////  Created by Wunderman on 12-1-3.//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.//#import "Car.h"@implementation Car- (Engine *) engine {    return engine;}- (void) setEngine:(Engine *) newEngine {    engine = newEngine;}- (Tire *)tireAtIndex: (int) index {    if (index >3 || index < 0) {        NSLog(@"bad index %d", index);        exit(1);    }    return tires[index];}- (void) setTire: (Tire *) tire         atIndex: (int) index {    if (index >3 || index < 0) {        NSLog(@"bad index %d", index);        exit(1);    }    tires[index] = tire;}- (void) print {    NSLog(@"%@", engine);    NSLog(@"%@", tires[0]);    NSLog(@"%@", tires[1]);    NSLog(@"%@", tires[2]);    NSLog(@"%@", tires[3]);}@end
?

?

?

?

?

?

?

?

读书人网 >编程

热点推荐