Coredata和NSManagedObject生成的子类与关系 [英] Coredata and Generated subclass for NSManagedObject with relations

查看:140
本文介绍了Coredata和NSManagedObject生成的子类与关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用选项创建NSManagedObject子类为2个实体生成子类Xcode创建了4个文件...好,我不明白如何使用创建的函数来管理关系

Generating subclasses for 2 Entities with the option "Create NSManagedObject SubClass" Xcode creates 4 files ... well, i can't understand how to use functions created to manage relations

@interface Person (CoreDataGeneratedAccessors)

- (void)addPersonContactObject:(Contacts *)value;
- (void)removePersonContactObject:(Contacts *)value;
- (void)addPersonContact:(NSSet *)values;
- (void)removePersonContact:(NSSet *)values;

@end

这只是接口,我要实现这些方法?和什么时候可以使用?
我发现一对多关系是用NSSet管理的...不是一个可变对象是我的怀疑与什么有关的吗?

This is interface only, have i to implement these methods? and when they can be useful ? I found that one to many relations are managed with NSSet... not a mutable object is my doubt something related with that ?

推荐答案

您不必实现它们,它们被声明为阻止编译器警告此处

You don't have to implement them, they are declared there to prevent compiler warnings as described here.

您可以使用* Object来从关系中添加和删除单个项目,但是通常更容易从一个(即,从联系人设置人,而不是从另一个方向)。

You'd use the *Object ones to add and remove individual items from the relationship, but it is usually simpler to manage that from the "one" side of the one-to-many relationship (that is, to set the person from the contact, not the other way round).

这篇关于Coredata和NSManagedObject生成的子类与关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆