NSFetchedResultsController calls didChangeObject delete instead of update

前端 未结 2 885
遇见更好的自我
遇见更好的自我 2021-01-03 21:05

This is the code, I save the model via Magical Record:

MagicalRecord.saveWithBlock({ (localContext) -> Void in
                    var localNotification =         


        
2条回答
  •  隐瞒了意图╮
    2021-01-03 21:53

    I know, late answer, but maybe helpful. I had the same problem with iOS 11.3 and Xcode 9.3 and it was driving me mad. The solution was to provide the correct data type in the arguments array for the predicate. After changing it from string interpolation to the actual expected type (NSNumber in that particular case), the correct NSFetchedResultsChangeType was Update instead of Delete.

    I chose string interpolation, because the data type (Bool in that particular case), was used as scalar type in the Core Data model and NSPredicate accepted the scalar type during compilation, but raised an runtime exception. Changing it to string interpolation fixed the runtime error and the predicate worked as expected, except the wrong NSFetchedResultsChangeType was called.

    So it seems the bug in Core Data still exists or maybe this was intended to force the correct data type usage.

提交回复
热议问题