【发布时间】:2013-10-03 17:42:05
【问题描述】:
我在我的应用程序中使用 Magical Record,并希望为用户添加添加“注释”的功能,它是“条目”的子级。
我添加了这段代码:
[MagicalRecord saveWithBlock: ^(NSManagedObjectContext *localContext) {
Note *newNote = [Note MR_createInContext: localContext];
newNote.content = noteContent;
newNote.name = @"User Note";
[self.entry addNotesObject: newNote];
}
completion: ^(BOOL success, NSError *error) {
if (error != nil)
{
// show alert
}
else if (success)
{
[[self tableView] reloadData];
}
}];
我在最后一行一直遇到的错误是“非法尝试在不同上下文中的对象之间建立关系'条目'”
我尝试将 'entry' 和 'newNote' 的上下文设置为 'localContext',但仍然遇到相同的错误。
我错过了什么?
【问题讨论】:
标签: ios core-data magicalrecord