• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data: how to prevent document being dirtied when chaging attributes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data: how to prevent document being dirtied when chaging attributes?


  • Subject: Re: Core Data: how to prevent document being dirtied when chaging attributes?
  • From: "Sean McBride" <email@hidden>
  • Date: Thu, 17 Jan 2008 12:10:37 -0500
  • Organization: Rogue Research

On 1/17/08 5:34 PM, Felix Franz said:

>> In a Core Data app, how should one model a property of an object
>> that a)
>> should be saved as part of the document b) should not participate in
>> undo c) should not dirty the document when changed and d) can be
>> easily
>> bound to?
>
>disabling undo-registration (as described in "Undo Management" <http://
>developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/
>cdUsingMOs.html#//apple_ref/doc/uid/TP40001803-207821-TPXREF148
> >) should do the trick. I see no reason
>why disabling undo-registration should break bindings in any way.

Felix,

Thanks for the link.  I had tried something like that with limited
success, but was missing the critical processPendingChanges.

So is it typical to do such a thing in an NSManagedObject subclass' KVC
setter?  Like so:

- (void)setName:(NSString*)value_
{
	NSManagedObjectContext* moc = [self managedObjectContext];
	NSUndoManager* undoMan = [moc undoManager];

	[moc processPendingChanges];
	[undoMan disableUndoRegistration];

	[self willChangeValueForKey:@"name"];
	[self setPrimitiveValue:value_ forKey:@"name"];
	[self didChangeValueForKey:@"name"];

	[moc processPendingChanges];
	[undoMan enableUndoRegistration];
}

Cheers,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

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

References: 
 >Core Data: how to prevent document being dirtied when chaging attributes? (From: "Sean McBride" <email@hidden>)
 >Re: Core Data: how to prevent document being dirtied when chaging attributes? (From: Felix Franz <email@hidden>)

  • Prev by Date: Re: Core Data: how to prevent document being dirtied when chaging attributes?
  • Next by Date: re: Core Data performance advice... creating relationships.
  • Previous by thread: Re: Core Data: how to prevent document being dirtied when chaging attributes?
  • Next by thread: CALayer content looks "blurry"
  • Index(es):
    • Date
    • Thread