0
我想通過傳遞父對象的屬性來調用對象的父對象的方法。 但我不斷收到此錯誤:訪問對象的父節點
expected specifier-qualifier-list before 'Wheel'
@interface Car : NSObject {
Wheel *w;
}
- (void)doCarStuff;
@end
@implementation Car
- (id)init {
if((self = [super init])) {
//w = [[Wheel alloc] init];
//w.parent = self;
}
return self;
}
- (void)doCarStuff {
NSLog(@"Car stuff");
}
@end
@interface Wheel : NSObject {
Car *parent;
}
@property (nonatomic, assign) Car *parent;
@end
@implementation Wheel
@synthesize parent;
- (id)init {
if((self = [super init])) {
[parent doCarStuff];
}
return self;
}
@end
這可能是因爲我要聲明的車輪前的汽車,反之亦然。 我敢打賭,解決方案非常簡單,我看不到它:P
現在,我得到這個錯誤,是至極更加混亂。 LD:重複的符號.objc_class_name_Wheel在.. collect2:LD返回1個退出狀態 命令/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2失敗,退出代碼1 – 2010-07-23 13:34:15
沒關係,我得到這個。 非常感謝你:) – 2010-07-23 13:46:32