Incoming iCloud updates break round-tripping of NSManagedObjectID.

Originator:atomicbird
Number:rdar://13044763 Date Originated:18-Jan-2013 02:39 PM
Status:Open Resolved:
Product:Mac OS X Product Version:10.8.2
Classification:Serious Bug Reproducible:Always
 
18-Jan-2013 02:39 PM Tom Harrington:
Summary:

Incoming iCloud updates break round-tripping of NSManagedObjectID.

Steps to Reproduce:

1. Build an app that uses Core Data's iCloud integration.

2. Listen for NSPersistentStoreDidImportUbiquitousContentChangesNotification in this app.

3. When this notification is posted, get one of the NSManagedObjectID instances contained in the notification.

4. Use the NSManagedObjectID to look up the corresponding NSManagedObject, using -[NSManagedObjectContext existingObjectWithID:error:]

5. Get the NSManagedObjectID for the object found in step 4.

Expected Results:

The managed object ID found in step 5 would match the one looked up from the incoming notification in step 3. Specifically:

a. -[NSObject isEqual:] would return YES when comparing the two NSManagedObjectIDs.

b. If one NSManagedObjectID were used as a key in an NSMutableDictionary, the other one could be used to look up the value for the key.


Actual Results:

The two managed object IDs do not match. Specifically,

a. isEqual: returns NO.

b. If one is used as a key in a mutable dictionary, the other one cannot be used to look up the value.

On investigation it develops that both the entity and URIRepresentation properties of the object IDs are identical (or at least that isEqual: returns YES when they are compared). However the persistentStore properties do not match.

The two NSPersistentStore objects use the same persistent store, have the same URL, identifier, etc. However the options dictionaries differ. For the NSManagedObjectID obtained in step 3 above, the persistent store's options dictionary contains a key named NSUbiquityImporterPrivateStoreKey. This key is not present in the corresponding dictionary for the persistent store for the NSManagedObjectID obtained in step 5.

On the basis of this difference, the two NSManagedObjectIDs don't match, even though they refer to the same instance in the same data store.

Regression:

None that I know of.

Notes:

The same issue exists if the NSManagedObjectID from step 5 were found by other means-- any managed object ID that is looked up from the data store would also fail to match for the same reason.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!