我正在使用具有單個NSManagedObjectContext的核心數據,並且正在爲主線程上的核心數據執行所有操作。錯誤描述中給出的新舊行是相同的,我希望有人可以解釋爲什麼會出現合併衝突。將合併策略設置爲覆蓋會導致應用程序在模擬器中運行至高CPU並且無響應。核心數據給與單個MOC和用於核心數據的主線程的合併衝突
然而,當我嘗試在一個實體更新管理對象,應用程序崩潰與以下錯誤,
NSMergeConflict (0x7144390) for NSManagedObject (0x7225db0) with objectID '0x721c0a0 <x-coredata://94349DC2-C441-4102-9C65-60737E940135/Locations/p1>' with oldVersion = 2 and newVersion = 3 and
old cached row = {\n AccountInfo = \"0x721bae0 <x-coredata://94349DC2-C441-4102-9C65-60737E940135/Account/p1>\";\n City = \"<null>\";\n Country = \"Russian Federation\";\n EntryStatusId = \"<null>\";\n ExitStatusId = \"<null>\";\n IsCorporateLocation = 1;\n IsVisible = 1;\n Latitude = 50;\n LocationId = 10003;\n Longitude = 40;\n Name = \"Test Location\";\n Radius = 304;\n State = \"Province of Voronezh\";\n Street = \"<null>\";\n Units = METER;\n Zip = \"<null>\";\n} and
new database row = {\n AccountInfo = \"0x7144560 <x-coredata://94349DC2-C441-4102-9C65-60737E940135/Account/p1>\";\n City = \"<null>\";\n Country = \"Russian Federation\";\n EntryStatusId = \"<null>\";\n ExitStatusId = \"<null>\";\n IsCorporateLocation = 1;\n IsVisible = 1;\n Latitude = 50;\n LocationId = 10003;\n Longitude = 40;\n Name = \"Test Location\";\n Radius = 304;\n State = \"Province of Voronezh\";\n Street = \"<null>\";\n Units = METER;\n Zip = \"<null>\";\n}
更新:如果我救了MOC每次更新對象後,該錯誤不會發生,但發生如果我更新所有的對象,然後保存MOC。任何人都知道這是爲什麼發生?
感謝您的更新!我面臨同樣的問題,這解決了它。我現在使用'refreshObject'更新對象後保存上下文,並沒有更多的衝突出現。 – csch 2015-04-17 18:17:35