Re: Detecting Managed Object Property Change From Undo Redo
Re: Detecting Managed Object Property Change From Undo Redo
- Subject: Re: Detecting Managed Object Property Change From Undo Redo
- From: Mike Abdullah <email@hidden>
- Date: Sun, 25 Jan 2015 09:20:53 +0000
> On 25 Jan 2015, at 06:35, Richard Charles <email@hidden> wrote:
>
> Core Data generated primitive accessors are used to get and set values from and to the managed object's private internal store. Core Data generated primitive accessors do not have change notification. If primitive accessors are present, Core Data will use them during undo and redo.
>
> A managed object may have resources that need to be updated when a property changes. During undo and redo primitive accessors are used to change the property but because primitive accessors do not have change notification there is no way for the managed object to be notified that the property has changed.
>
> The only solution seems to be to use custom primitive accessors that have change notification.
>
> What am I doing wrong?
You are mistaken. Core Data *does* fire KVO notifications during undo/redo. Its internal implementation does something along these lines:
[object willChangeValueForKey:key];
[object setPrimitiveValue:previousValue forKey:key];
[object didChangeValueForKey:key];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden