NSManagedObjectContextObjectsDidChangeNotification userInfo Dictionary

前端 未结 1 439
星月不相逢
星月不相逢 2021-01-24 17:26

I am using the NSManagedObjectContextObjectsDidChangeNotification notfication in my app, I already now how to use it. As I have used the below code to add the observer …

相关标签:
1条回答
  • 2021-01-24 17:43

    Looking at the documentation for NSManagedObject gives you an answer.

    A notification has three instance methods one of which is the -userInfo method which returns the userInfo dictionary.

    It looks like your syncKVO: method is incorrect; notification handlers should take the notification object as a parameter.

    The documentation for the notification you are looking for shows the keys that are in this dictionary for this notification and you can use something like this to get what you might need:

    - (void)syncKVO:(NSNotification *)notification {
        NSDictionary *userInfoDictionary = [notification userInfo];
        NSSet *deletedObjects = [userInfoDictionary objectForKey:NSDeletedObjectsKey];
    
        // do what you want with the deleted objects
    }
    
    0 讨论(0)
提交回复
热议问题