Re: Globaly unique NSManagedObjectID (some answers)
Re: Globaly unique NSManagedObjectID (some answers)
- Subject: Re: Globaly unique NSManagedObjectID (some answers)
- From: Alexander Lamb <email@hidden>
- Date: Fri, 6 Jan 2006 11:15:03 +0100
Ok, a simple test gave me a simple result:-) (it might be obvious to
many, but I feel it is important since the documentation is not 100%
clear AFAIK).
When you ask for the NSManagedObjectID of an object, yes it IS
globally unique.
However, that's NOT like that it is saved in the persistent store.
Indeed, look at a simple example here:
<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "file:///System/Library/DTDs/CoreData.dtd">
<database>
<databaseInfo>
<version>134481920</version>
<UUID>F2BB67E6-1FF8-4701-BF5A-87B0CF6FD034</UUID>
<nextObjectID>103</nextObjectID>
<metadata></metadata>
</databaseInfo>
<object type="PATIENT" id="z102">
<attribute name="firstname" type="string">Jean</attribute>
<attribute name="lastname" type="string">Dupond</attribute>
</object>
<object type="PATIENT" id="z103">
<attribute name="firstname" type="string">Max</attribute>
<attribute name="lastname" type="string">Muller</attribute>
</object>
</database>
I have two objects saved. They have an ID z102 and z103. There is a
UUID but it is at the store level.
When I ask for the url of the object ID, I get:
x-coredata://F2BB67E6-1FF8-4701-BF5A-87B0CF6FD034/Patient/p103
Which is actually:
"x-coredata://" + the UUID of the Store + the entity name + the
object ID
That's very different and will unfortunately not solve the problem.
It is a pitty CoreData was not initially designed with distributed
data stores in mind.
Indeed, if I want to have objects "traveling" from one store to
another (think iSync between database, for example, I take my laptop
home and still want to work on my patient records) then I can't rely
on the NSManagedObjectID to have my objects uniquely identified
between stores.
I will need to have another field to store my own globaly unique ID.
Alex
--
Alexander Lamb
email@hidden
On Jan 5, 2006, at 8:09 PM, Alexander Lamb wrote:
Well from the documentation:
A managed object ID uniquely identifies the same managed object
both between managed object contexts in a single application, and
in multiple applications (as in distributed systems).
So it IS globaly unique. The problem is:
- does it contain a reference to its data store
- how do I store an object with a unique ID coming from another
store in a second store (as in distributed systems)
--
Alexander Lamb
email@hidden
On Jan 5, 2006, at 7:24 PM, I. Savant wrote:
In addition to (or to supplement) Matt's advice, you may want to
check this out:
http://www.cocoadev.com/index.pl?IDentifiers
--
I.S.
On Jan 5, 2006, at 1:15 PM, Matt Emerson wrote:
On Jan 5, 2006, at 5:49 AM, Alexander Lamb wrote:
I would like to send objects (NSManagedObjects or subclasses)
from one process to another. Each process being a CoreData
application with it's own data store.
I understand that once an object is persistant it gets an
NSManagedObjectID. This ID is globally unique.
I believe that an NSManagedObjectID is unique only within its
persistent store.
It sounds like you might want to add an ID attribute of your own
to your objects.
-matt
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
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
_______________________________________________
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