• 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: CoreData: Using willSave to update timestamps causes hang?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData: Using willSave to update timestamps causes hang?


  • Subject: Re: CoreData: Using willSave to update timestamps causes hang?
  • From: mmalcolm crawford <email@hidden>
  • Date: Sat, 4 Jun 2005 02:04:13 -0700


On Jun 3, 2005, at 2:57 PM, Jesse Grosjean wrote:

I can bind this to my edited checkbox (i'm using a checkbox to indicated edited status for now instead of a darkened icon) and it almost works, but the checkbox isn't always updated when it should be since no KVC notifications are not being sent for the "edited" key. But when I try to remedy this by calling the willChangeValueForKey: and didChangeValueForKey: methods when the managed object context is updated or saved I run into all sorts of problems.

Umm, as I wrote in another thread recently, you can't just sprinkle your code with change notifications and hope stuff works. The first strategy should be to simply register 'edited' as a key that's dependent on the other property values:


setKeys:triggerChangeNotificationsForDependentKey:
<http://developer.apple.com/documentation/Cocoa/Reference/ Foundation/ObjC_classic/Protocols/NSKeyValueObserving.html#// apple_ref/doc/uid/20002299-BBCHIBID>



I'm not sure offhand if that will be all that's required in this case, but if it's not then I'd be more inclined to reduce your managedObjectContextObjects* method to:


- (void)managedObjectContextObjects*:(NSNotification *)notification {
    [tableView reloadData];
}

At least this will provide a better starting point...




It's very simple to get this almost working, to do that I have created this edited method in my NSManagedObject subclass:

- (BOOL)edited {
    return [self isInserted] || [[self changedValues] count] > 0;
}

Is there any reason why isUpdated didn't work?
    return [self isInserted] || [self isUpdated];


mmalc

_______________________________________________
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: CoreData: Using willSave to update timestamps causes hang?
      • From: mmalcolm crawford <email@hidden>
References: 
 >Re: CoreData: Using willSave to update timestamps causes hang? (From: Jesse Grosjean <email@hidden>)

  • Prev by Date: Re: Catching edits to items in a table view using bindings
  • Next by Date: Re: CoreData: Using willSave to update timestamps causes hang?
  • Previous by thread: Re: CoreData: Using willSave to update timestamps causes hang?
  • Next by thread: Re: CoreData: Using willSave to update timestamps causes hang?
  • Index(es):
    • Date
    • Thread