Re: willChangeValueForKey, Ivars and Core Data
Re: willChangeValueForKey, Ivars and Core Data
- Subject: Re: willChangeValueForKey, Ivars and Core Data
- From: Jim Correia <email@hidden>
- Date: Tue, 20 Sep 2005 17:14:56 -0400
On Sep 20, 2005, at 12:33 PM, Jim Correia wrote:
If you disable undo registration in your setter, then the document
won't be marked dirty, but you'll get a "phantom" undo state which
does nothing, and the document *is* marked dirty on redo.
I'm not sure what the workaround is, if any.
Seems like the following is a possible workaround. The idea is to
make sure NSObject's implementation of will/didChangeValueForKey,
bypassing the NSManagedObjectImplementation for the iVar accessors.
Perhaps someone who knows enough about the runtime can comment as to
just how skanky this is, and whether or not you should actually do
this in shipping code.
- (void)setComment:(NSString *)comment
{
if (comment != myComment)
{
IMP willChangeValueForKey = [NSObject
instanceMethodForSelector: @selector(willChangeValueForKey:)];
IMP didChangeValueForKey = [NSObject
instanceMethodForSelector: @selector(didChangeValueForKey:)];
willChangeValueForKey(self, @selector
(willChangeValueForKey:), @"comment");
[myComment release];
myComment = [comment copy];
didChangeValueForKey(self, @selector(didChangeValueForKey:),
@"comment");
}
}
_______________________________________________
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