Objective c 将观察员添加到NSArrayController以监视值的变化
我有一个绑定到NSTableView的NSArraycontroller,并且NSTableView上的值可以编辑。我添加了一个观察者来检测NSArraycontoller的值何时因编辑而发生变化 这是我的密码:Objective c 将观察员添加到NSArrayController以监视值的变化,objective-c,cocoa,core-data,Objective C,Cocoa,Core Data,我有一个绑定到NSTableView的NSArraycontroller,并且NSTableView上的值可以编辑。我添加了一个观察者来检测NSArraycontoller的值何时因编辑而发生变化 这是我的密码: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(mocDidChangeNotificati
[[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;数据:{
类别=新类别;
})
)}
你们中有谁知道我如何跟踪旧值
我非常感谢你的帮助