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