NSMergeConflict on iOS7

后端 未结 6 2051
时光取名叫无心
时光取名叫无心 2021-02-06 01:29

I have updated my app to support iOS 7 and have been faced with the problem that on one of screens in my [context save]; I get the following error:

         


        
6条回答
  •  星月不相逢
    2021-02-06 02:01

    I just spent two days debugging the exact same error. The difference between your app and mine is that mine only accesses core data from the main thread, so the merge error was even more puzzling.

    In our case I narrowed it down to the fact that we had a unidirectional relationship - A has many Bs (modeled as an NSSet), but B doesn't know its A. We had a method that modified both an A and a B, and would cause a merge error when we went to save those changes. This code worked fine for a long time on both iOS 5 & 6, and only started to fail on iOS 7.

    It's true that adding a merge policy will make the error go away, but it might also mask other errors. In our case we'd rather see those errors than risk having an inconsistent DB.

    Changing the relationship to bidirectional made the error go away. The back links aren't necessary for our app, but they aren't hurting either. (And happily, changing this relationship was handled correctly as a lightweight migration - core data automatically filled in those back links for us.)

提交回复
热议问题