title: Core Data: Fetching Relationship Attributes
body: <p>Can't seem to figure out the trick to fetch an attribute from a relationship when limiting the fetch to a number of properties. In the code below "thumbnail" is a transformable UIImage attribute of the entity "Photo". That always comes back fine in the array of dictionaries with the key "thumbnail". What I cannot figure out is the second property/attribute where "previewImage" is a relationship in Photo to another entity named "Image" that has a transformable attribute "uiImage" (which is a UIImage).</p>
  
  <p>I've tried this:</p>
  
  <pre><code>[fetchRequest setPropertiesToFetch:@[@"thumbnail", @"previewImage.uiImage"]];
  </code></pre>
  
  <p>but I got this error:</p>
  
  <pre><code>-[NSExpressionDescription valueTransformerName]: unrecognized selector sent to instance 0x13078920
  </code></pre>
  
  <p>and I've tried this:</p>
  
  <pre><code>[fetchRequest setPropertiesToFetch:@[@"thumbnail", @"previewImage"]];
  </code></pre>
  
  <p>where I do get two items in each dictionary</p>
  
  <pre><code>{
     previewImage = "0xbabba90 &lt;x-coredata://03FF7129-1345-4BAE-A74E-2FF5A2B38CDC/Image/p5&gt;";
     thumbnail = "&lt;UIImage: 0xbabbc60&gt;";
  }
  </code></pre>
  
  <p>but when I try to use that "Image" object as below</p>
  
  <pre><code>NSDictionary *dict = [self.photos objectAtIndex:0];
  Image *theImage = (Image *)[dict objectForKey:@"previewImage"];
  [self.delegate photoCollectionViewController:self didSelectPreviewImage:theImage.uiImage];
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>"[_NSObjectID_48_0 uiImage]: unrecognized selector sent to instance 0xbabba90"
  </code></pre>
  
  <p>And I've even thrown this in the request</p>
  
  <pre><code>[fetchRequest setRelationshipKeyPathsForPrefetching:@[@"previewImage.uiImage"]];
  </code></pre>
  
  <p>So, I guess I'm flailing and not getting this. Any help would be appreciated. Thanks!</p>
  
  <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"Photo" inManagedObjectContext:self.managedObjectContext];
  [fetchRequest setEntity:entity];
  [fetchRequest setResultType:NSDictionaryResultType];
  </code></pre>