Core Data: Updating MOC doesn't make document dirty when using NSTextField
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