Core Data: objectRegisteredForID: vs objectWithID: question / Cross store relationship problem
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