与 nsmanagementObject 的奇怪关系
我有来自同一实体的多个 NSmanagementObject(我们称为 PersonEntity)。
该实体与另一个实体(我们称为 BusinessEntity)存在“对多”关系。
当我填充商店时,我创建 BusinessEntity 托管对象。 在我将此 BusinessEntity 托管对象添加到我的第一个 PersonEntity 托管对象之后。
[(Person *)entity1 addBusinessObject:businessEntity];
[(Person *)entity2 addBusinessObject:businessEntity];
addBusinessObject 函数(由 XCode 生成):
- (void)addBusinessObject:(NSManagedObject *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
[self willChangeValueForKey:@"business" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"business"] addObject:value];
[self didChangeValueForKey:@"business" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
}
此功能有效,但仅在填充之后才有效。
如果我保存商店,则仅存在entity1和businessEntity之间的关系。
我在entity2和businessEntity之间没有关系。
真的很奇怪
PS:我的两个实体是 NSManagedObject 的子类,用于未定义的属性和瞬态属性。
感谢您的帮助
i have multiple NSmanagedObject from the same entity ( we call PersonEntity).
This entity have a relationship "to-many" for another entity (we call BusinessEntity).
when i populate my store, i create the BusinessEntity managedObject.
After i add this BusinessEntity managedObject to my first PersonEntity managedObject.
[(Person *)entity1 addBusinessObject:businessEntity];
[(Person *)entity2 addBusinessObject:businessEntity];
the addBusinessObject function ( generate by XCode ) :
- (void)addBusinessObject:(NSManagedObject *)value {
NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
[self willChangeValueForKey:@"business" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[[self primitiveValueForKey:@"business"] addObject:value];
[self didChangeValueForKey:@"business" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
[changedObjects release];
}
this work but only just after the populate.
If i save the store, only the relationShip between the entity1 and the businessEntity exist.
I have no relationShip between entity2 and businessEntity.
Really strange
PS: my two Entity are subclass of NSManagedObject for use with undefined property, and transient property.
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于苹果文档核心数据编程指南
我已经阅读了这篇重要的文字:
现在开始工作了
On the apple documentation Core Data Programming Guide
i have read this important text :
Now it's work