• 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
Core Data: objectRegisteredForID: vs objectWithID: question / Cross store relationship problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: objectRegisteredForID: vs objectWithID: question / Cross store relationship problem


  • Subject: Core Data: objectRegisteredForID: vs objectWithID: question / Cross store relationship problem
  • From: Guillaume Rager <email@hidden>
  • Date: Mon, 27 Mar 2006 20:37:24 +0200

Hi list,

Just a small question about NSManagedObjectID.

I have to link 2 different objects, in 2 different stores (cross store relationship), i'm using (NSURL) URIRepresentation. When i save the context and quit my application, the URIRepresentations are stored correctly in the database.
But when the database is reloaded, if the object represented by the URIRepresentation has been deleted (during another application session for example), there is a BIG problem because I do not have any solution to know if the represented object (the destination of the cross store relation ship) still exists or not ?


i'm using managedObjectIDForURIRepresentation then objectWithID: but this method *ALWAYS* returns an object (with no underlying datas because the object has been deleted).
Using objectRegisteredForID: is not better, because it returns nil IF THE OBJECT HAS NOT BEEN REGISTERED (fetched?), OR IF THE OBJECT DOES NOT EXIST. I can not afford a "fetch all" each time, then use objectForRegisteredID: and check if nil to be sure the represented object still exists...


By the way, where is "registered" for a NSManagedObject defined, what does it means?

Currently i'm forced to catch the "Core data could not fulfill a fault" exception to check if the underlying data exists... and nullify the relationship destination if necessary

Scary monday... what about tomorrow :-)


Guillaume Rager

PS : resent because cocoa-dev seems to be broken

---
GUMITECH France
http://www.gumitech.com


_______________________________________________ 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
  • Prev by Date: Re: Draw a single bitmap multiple times into an NSView?
  • Next by Date: Re: Force NSPopUpButtonCell to edit like a text cell
  • Previous by thread: Popup Menu Button & Sort Descriptors
  • Next by thread: Core Data: objectRegisteredForID: vs objectWithID: question / Cross store relationship problem
  • Index(es):
    • Date
    • Thread