0

如何从持久存储中强制重新获取 nsmanagedobject 的关系?

关系是一个nsset。它的内容可能已被其他上下文更改。更改可能包括集合中的新元素、集合中现有元素的删除和更新。

4

1 回答 1

0

如果您有不同的 NSManagedObjectContexts,则需要监听“保存”。

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(updateStuff:)
                                                 name:NSManagedObjectContextDidSaveNotification
                                               object:nil];

完成后,您可以“刷新”您的数据。

- (void)updateStuff:(NSNotification *)notification
{
    NSArray *array = [myEntity.theRelationship allObjects];
}
于 2012-09-03T13:53:02.390 回答