Re: Core Data: Updating MOC doesn't make document dirty when using NSTextField
Re: Core Data: Updating MOC doesn't make document dirty when using NSTextField
- Subject: Re: Core Data: Updating MOC doesn't make document dirty when using NSTextField
- From: Matt Smith <email@hidden>
- Date: Tue, 31 Oct 2006 16:06:13 -0800
I was able to track this problem down to some other trickery I was
doing when creating the document, please disregard this problem.
Thanks,
Matthew Smith
On Oct 31, 2006, at 10/31/06 2:34 PM, Matt Smith wrote:
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
_______________________________________________
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