1
我試圖將現有數據從本地存儲播種到啓用iCloud的存儲。當我嘗試從本地管理對象訪問的關係對象,以下異常被拋出,從本地持久性存儲向iCloud存儲區播種數據時的管理關係
> illegal attempt to establish a relationship between objects in
> different contexts
這就是我要做的。在提前
NSEntityDescription *entity = [recurringExpense entity];
RecurringExpense *newRecExpense = [[RecurringExpense alloc]initWithEntity:entity insertIntoManagedObjectContext:moc];
newRecExpense.category = recurringExpense.category;
[moc assignObject:newRecExpense toPersistentStore:store];
感謝。
哪裏'category'對象創建?錯誤消息表明它屬於不同的上下文。 – 2013-03-17 21:17:41
'recurringExpense'來自不同的上下文。 P.S. 我改變了我的計劃並打算使用[https://github.com/alekseyn/iCloudStoreManager](https://github.com/alekseyn/iCloudStoreManager)來處理種子和管理商店。 – 2013-03-18 12:25:32