0
我有一个名为“客户端”的实体,每个客户端可以有多个“属性”。 CoreData为我添加一个新的属性给我的客户端类创建方法,但我不明白这个的目的。有没有在所有任何区别:在CoreData中创建新的多对多关系的正确方法是什么?
Property *newProperty = [NSEntityDescription insertNewObjectForEntityForName:@"Property" inManagedObjectContext:self.managedObjectContext];
newProperty.name = @"[New Property]";
newProperty.client = self.currentClient;
这:
Property *newProperty = [NSEntityDescription insertNewObjectForEntityForName:@"Property" inManagedObjectContext:self.managedObjectContext];
newProperty.name = @"[New Property]";
[self.currentClient addPropertiesObject:newProperty];
据我所知,这两个做同样的事情;他们只是将我的新房产与正确的客户相关联。一个比另一个更受欢迎;有没有什么区别?我只是想确保我不会错过自动生成的“addPropertiesObject”方法的整个点。谢谢,
谢谢!我会坚持我当时所做的; newProperty.client = self.currentClient,因为它感觉更简单,它不是对Client类或视图中的某些内容的响应。 – GendoIkari 2010-10-14 20:08:01