Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 将观察员添加到NSArrayController以监视值的变化_Objective C_Cocoa_Core Data - Fatal编程技术网

Objective c 将观察员添加到NSArrayController以监视值的变化

Objective c 将观察员添加到NSArrayController以监视值的变化,objective-c,cocoa,core-data,Objective C,Cocoa,Core Data,我有一个绑定到NSTableView的NSArraycontroller,并且NSTableView上的值可以编辑。我添加了一个观察者来检测NSArraycontoller的值何时因编辑而发生变化 这是我的密码: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mocDidChangeNotificati

我有一个绑定到NSTableView的NSArraycontroller,并且NSTableView上的值可以编辑。我添加了一个观察者来检测NSArraycontoller的值何时因编辑而发生变化

这是我的密码:

[[NSNotificationCenter defaultCenter] addObserver: self
                                             selector: @selector(mocDidChangeNotification:)
                                                 name:NSManagedObjectContextObjectsDidChangeNotification
                                               object: nil];
我可以检测到值何时发生了更改,我可以获取新值,但我无法从通知中获取旧值

- (void)mocDidChangeNotification:(NSNotification *)notification
{

    NSLog(@"changes %@", [notification.userInfo valueForKeyPath:NSUpdatedObjectsKey]);

}
控制台输出:

changes {(
    <Categories: 0x6000000a27c0> (entity: Categories; id: 0x40000b <x-coredata://3C4A59E5-F730-4DF0-BF7F-CF2A88A2979F/Categories/p1> ; data: {
    category = newCategory;
})
)}
更改{(
(实体:类别;id:0x40000b;数据:{
类别=新类别;
})
)}
你们中有谁知道我如何跟踪旧值

我非常感谢你的帮助