I'm confused by the following code. What I'm trying to do is store a reference 
in a DogManagedObject transformable property, to a CatManagedObject, then 
retrieve the Cat from the Dog at a later date.
However, when I log the output I get a class of 'Dog' rather than 'Cat'.
Any ideas?

        //add the NSData
        NSURL *uri = [[catManagedObject objectID] URIRepresentation];
        NSData *uriData = [NSKeyedArchiver archivedDataWithRootObject:uri];
        
        //selectedInstrument is a transformable property
        dogManagedObject.selectedInstrument = uriData;


        [_managedObjectContext save:&error];
        
        
      
        //retrive the NSData
        
        NSData * data = (NSData *) dogManagedObject.selectedInstrument;
        NSURL *uri2 = [NSKeyedUnarchiver unarchiveObjectWithData:data];
        NSManagedObjectID *moID = [_persistentStoreCoordinator 
managedObjectIDForURIRepresentation:uri2];
        CatManagedObject * cat = (CatManagedObject *)[_managedObjectContext 
objectWithID:moID];
        
        

        NSLog(@"log %@", cat);
Ouputs....



log <DogManagedObject: 0x7853840> (entity: DogManagedObject; id: 0x7853f90 
<x-coredata://D9B53F16-BE02-4125-ACF1-ABF50835F296/DogManagedObject/p1> ; data: 
{
    cats = "<relationship fault: 0x784f670 'cats'>";
    selectedCat = "<62706c69 73743030 d4010203.... etc
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to