Re: How to enable Undo only for subgroup of managed objects?
Re: How to enable Undo only for subgroup of managed objects?
- Subject: Re: How to enable Undo only for subgroup of managed objects?
- From: Chad Seldomridge <email@hidden>
- Date: Thu, 21 Sep 2006 10:52:27 -0600
I would read the KVC documentation and make sure your setter methods KVC compliant and are being called. Either that or log a debug string inside the setter. It could be that your undo code isn?t being called because the KVC system is setting your variable via some method other than your setter.
>Date: Thu, 21 Sep 2006 16:16:19 +0200
>From: "Arthur C." <email@hidden>
>Subject: RE: How to enable Undo only for subgroup of managed objects?
>To: email@hidden
>Cc: email@hidden
>Message-ID: <email@hidden>
>Content-Type: text/plain; format=flowed
>
>According to the Core Data programming guide, page 57, a solution would be
>as follows:
>
>NSManagedObjectContext *moc = [[NSApp delegate] managedObjectContext];
>[moc processPendingChanges]; // flush operations for which you want undos
>[[moc undoManager] disableUndoRegistration];
>
>// do things for which you don't want undo
>
>[moc processPendingChanges]; // flush operations for which you do not want
>undos
>[[moc undoManager] enableUndoRegistration];
>
>I would then put this code in the setter methods of some objects, for
>example:
>
>- (void)setName:(NSString *)value
>{
>NSManagedObjectContext *moc = [[NSApp delegate] managedObjectContext];
>[moc processPendingChanges];
>[[moc undoManager] disableUndoRegistration];
>
>[self willChangeValueForKey: @"name"];
> [self setPrimitiveValue: value forKey: @"name"];
> [self didChangeValueForKey: @"name"];
>
>[moc processPendingChanges];
>[[moc undoManager] enableUndoRegistration];
>}
>
>But this does not appear to work (changes can still be undone). However when
>I put the undo disable / enable code outside of the setter method, undo is
>disabled as expected:
>
><disable undo>
>[myObject setName: somevalue];
><enable undo>
>
>Is this expected behaviour? I would rather like to have the undo
>disabling/enabling inside the setter method, as that would simply lead to
>less code.
>
>
>Best regards,
>
>Arthur C.
>
>>I have a Core Data application in which I would like some objects to have
>>an undo capability, and others not.
>>For example, there are some objects which the user can change (which we
>>want to be undo enabled), and objects that get changed as the program runs,
>>for example by incoming I/O, network traffic etc. (no undo wanted).
>>When the user tries to 'undo' some change, the latest change is undone,
>>regardless what type of object was changed. So this will normally be an
>>automatically updated object.
>>
>>Question: can I disable 'undo' for a specific set of objects in a managed
>>object context?
>>
>>A solution would be either to throw the automatically changed objects out
>>of the managed object context, or to create a second managed object
>>context.
>>I would like to know if there is a simpler solution, or that one of the
>>above is really preferred.
>>
>>
>>Best regards,
>>
>>Arthur C.
>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden