• 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: willChangeValueForKey, Ivars and Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: willChangeValueForKey, Ivars and Core Data
      • From: Scott Ahten <email@hidden>
References: 
 >willChangeValueForKey, Ivars and Core Data (From: Scott Ahten <email@hidden>)
 >Re: willChangeValueForKey, Ivars and Core Data (From: Jim Correia <email@hidden>)
 >Re: willChangeValueForKey, Ivars and Core Data (From: Scott Ahten <email@hidden>)
 >Re: willChangeValueForKey, Ivars and Core Data (From: Jim Correia <email@hidden>)

  • Prev by Date: Can't get image smoothing to happen
  • Next by Date: [NSUndoManager undoMenuItemTitle]
  • Previous by thread: Re: willChangeValueForKey, Ivars and Core Data
  • Next by thread: Re: willChangeValueForKey, Ivars and Core Data
  • Index(es):
    • Date
    • Thread