• 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
Core Data: Updating MOC doesn't make document dirty when using NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: Updating MOC doesn't make document dirty when using NSTextField


  • Subject: Core Data: Updating MOC doesn't make document dirty when using NSTextField
  • From: Matt Smith <email@hidden>
  • Date: Tue, 31 Oct 2006 14:34:35 -0800

Hello,

I have a couple NSTextField's that are bound to a model objects attributes ( first name, last name etc.). When I modify the values in these text fields the document is not becoming dirty. However as soon as I go to the Edit menu the document becomes dirty. I believe the reason why it makes the document dirty is after you go to the edit menu it seems to validate the Redo menu item which checks for any changes in the MOC and registers an undo grouping via - [NSManagedObjectContext _registerUndoForModifiedObjects:]. So my question is why is it not grouping an undo around the setting the new value in the MOC. My Accessor methods look like the following:

In my Person class (which is a subclass of _Person)
- (void)setFirstName:(NSString *)value
{
[super setFirstName:value];
[self setName:[NSString stringWithFormat:@"%@ %@", [self firstName], [self lastName]]];
[self setHasBeenModified:YES];
}


In my _Person class (subclass of NSManagedObject)

- (void)setFirstName:(NSString *)value
{
	[self willChangeValueForKey:@"firstName:];
	[self setPrimitiveValue:value forKey:@"firstName"];
	[self setUpdatedByAndDate];
	[self didChangeValueForKeY:@"firstName"];
}

A few other interesting things:

1.) Using an NSTextView does not have this problem.
2.) Putting a beginUndoGrouping around the accessor methods such as - (void)setFirstName:(NSString *)value fixes the problem.


Thanks,
Matthew Smith
_______________________________________________
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


  • Follow-Ups:
    • Re: Core Data: Updating MOC doesn't make document dirty when using NSTextField
      • From: Matt Smith <email@hidden>
  • Prev by Date: Re: Display a NSView under another NSView
  • Next by Date: [NSCalendar currentCalendar] leak
  • Previous by thread: [MEET] November CocoaHeads Meetings
  • Next by thread: Re: Core Data: Updating MOC doesn't make document dirty when using NSTextField
  • Index(es):
    • Date
    • Thread