Managed Object URI's not working?
Managed Object URI's not working?
- Subject: Managed Object URI's not working?
- From: "John R. Timmer" <email@hidden>
- Date: Sun, 02 Dec 2007 11:07:47 -0500
Greeetings -
I'm trying to store a list of Managed Object IDs separately from my
data store. Since IDs only become valid after a save, I catch them
using the saved objects notification:
- (void) managedObjectsSaved: (NSNotification *) theNotification {
[[theNotification object] lock];
@synchronized (objectIDs) {
NSArray *theIDs = [[theNotification userInfo] valueForKey:
NSInsertedObjectsKey];
NSManagedObjectID *anID;
for ( NSManagedObject *anItem in theIDs ) {
anID = [anItem objectID];
if ( [anID isTemporaryID] )
NSLog( @"problem" );
else
[objectIDs addObject: [[anID URIRepresentation] absoluteString]];
}
Nothing gets logged, the Array fills up with objects that appear
proper (<string>x-coredata://7F300951-22DD-4C55-8F1B-C533BA0B8336/
ItemWrapper/p17</string>
), and it saves to a file nicely. Everything looks good.
Problems arise when i try to use these to use these to grab objects.
The URL appears just as valid, but the Persistent Store Coordinator
can never find a valid corresponding ID.
for ( loopCounter = 0; loopCounter < theLimit; loopCounter++ ) {
objectURL = [NSURL URLWithString: [theIDArray objectAtIndex:
loopCounter]];
theObjID = [persistentStoreCoordinator
managedObjectIDForURIRepresentation: objectURL];
if ( theObjID != nil )
[theIDArray replaceObjectAtIndex: loopCounter withObject:
[persistentStoreCoordinator managedObjectIDForURIRepresentation:
objectURL]];
else
NSLog ( [objectURL description] ) ;
}
Any advice on what I'm doing wrong would be extremely welcome.
Cheers,
John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden