Matt W,
首先,不要与Core Data争斗。你会输的。
二,请显示一些代码。我怀疑你可能不会像你认为的那样使用关系。
第三,当我对你的问题感兴趣时,我写了一个树的简单例子。下面是一些代码:
的自我指涉类:
@interface ToMany : NSManagedObject
@property (nonatomic, retain) NSDate * date;
@property (nonatomic, retain) NSSet *children;
@property (nonatomic, retain) ToMany *parent;
@end
代码,使用类没有任何编译器错误:
ToMany *parent = [NSEntityDescription insertNewObjectForEntityForName: kToManyEntity
inManagedObjectContext: self.managedObjectContext];
parent.date = NSDate.date;
ToMany *child1 = [NSEntityDescription insertNewObjectForEntityForName: kToManyEntity
inManagedObjectContext: self.managedObjectContext];
child1.date = parent.date;
child1.parent = parent;
ToMany *child2 = [NSEntityDescription insertNewObjectForEntityForName: kToManyEntity
inManagedObjectContext: self.managedObjectContext];
child2.date = parent.date;
child2.parent = parent;
我想我已经实现你的问题的说明。你究竟在担心什么?
Andrew