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

willChangeValueForKey, Ivars and Core Data


  • Subject: willChangeValueForKey, Ivars and Core Data
  • From: Scott Ahten <email@hidden>
  • Date: Mon, 19 Sep 2005 01:14:28 -0400

I have a subclass of NSManagedObject with a transient attribute that is calculated from other attributes of the entity.

A NSTimer is used to calculate and update this value every second, which is displayed in a NSTableView column in my UI using KVO. However, when this attribute is set, a dark dot is displayed in the close button and the document is flagged as "dirty". Since this attribute is set to transient in my CoreData model, not used to set other persistent properties, nor are any persistent attributes "dependent" on this attribute, I'm not sure why the document thinks it's dirty and needs to be saved.

In an attempt to resolve this issue, I've created a ivar for the attribute in my NSMangedObject subclass and manage it's storage myself. After creating my own accessor methods, setting this value no longer marks my document as dirty, but the table column is not notified of the change. Wrapping the assignment in my accessor with willChangeValueForKey: and didChangeValueForKey: calls updates the table, but marks the document as dirty even though this value is no longer and attribute of my CoreData model and I'm managing my own storage.

- (void)setTimeInHMS:(NSString *)value
{

    if (HMSString != value) {

        [self willChangeValueForKey:@"timeInHMS"];
        [HMSString autorelease];
        HMSString = [value retain];
        [self didChangeValueForKey:@"timeInHMS"];

}

How do I avoid setting my document as dirty yet notify any objects observing this value that it has changed?

Thanks,

- Scott




- - - :: email@hidden :: http://www.pixelfreak.net - - -


_______________________________________________ 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: Jim Correia <email@hidden>
    • Re: willChangeValueForKey, Ivars and Core Data
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: Standard Input/Output
  • Next by Date: [JOB] Port IDL app to OS X
  • Previous by thread: Re: Standard Input/Output
  • Next by thread: Re: willChangeValueForKey, Ivars and Core Data
  • Index(es):
    • Date
    • Thread