title: Core Data fetched property $FETCHED_SOURCE resolves to an object ID
body: <p>In a Core Data fetched property expression, apparently <code>$FETCH_SOURCE</code> resolves to an <em>object ID</em> instead of the object itself. This caused an exception "class is not key-value coding...". Which is true since it's the object that responds to that key.</p>
  
  <p>I would like to use the source object's property value(s) as part of a fetched property's predicate.</p>
  
  <p>Any idea how to fix this?</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[&lt;_NSObjectID_48_0 0x10101b200&gt; valueForUndefinedKey:]: this class is not key value coding-compliant for the key messageType.'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x00007fff92ba00c6 __exceptionPreprocess + 198
      1   libobjc.A.dylib                     0x00007fff8f85e3f0 objc_exception_throw + 43
      2   CoreFoundation                      0x00007fff92c34249 -[NSException raise] + 9
      3   Foundation                          0x00007fff9518b08c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 238
      4   Foundation                          0x00007fff950d2df9 -[NSObject(NSKeyValueCoding) valueForKey:] + 400
      5   Foundation                          0x00007fff950f36a8 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 341
      6   Foundation                          0x00007fff950a3489 -[NSFunctionExpression expressionValueWithObject:context:] + 751
      7   CoreData                            0x00007fff88cbbdda -[NSSQLSimpleWhereIntermediate initWithPredicate:inScope:] + 618
      8   CoreData                            0x00007fff88cbb672 -[NSSQLGenerator generateWhereIntermediatesInContext:] + 162
      9   CoreData                            0x00007fff88cbb010 -[NSSQLGenerator generateIntermediatesForFetchInContext:countOnly:] + 416
      10  CoreData                            0x00007fff88cb7d30 -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 400
      11  CoreData                            0x00007fff88cb7a97 -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 471
      12  CoreData                            0x00007fff88cb76b6 -[NSSQLCore newRowsForFetchPlan:] + 118
      13  CoreData                            0x00007fff88cb6f2e -[NSSQLCore objectsForFetchRequest:inContext:] + 526
      14  CoreData                            0x00007fff88cb6a91 -[NSSQLCore executeRequest:withContext:error:] + 225
      15  CoreData                            0x00007fff88cb5f72 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 2114
      16  CoreData                            0x00007fff88cb4309 -[NSManagedObjectContext executeFetchRequest:error:] + 537
      17  CoreData                            0x00007fff88cfca4e -[NSManagedObjectContext(_NestedContextSupport) _parentObjectsForFetchRequest:inContext:error:] + 414
      18  CoreData                            0x00007fff88d3072a __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke_0 + 634
      19  libdispatch.dylib                   0x00007fff8b2710b6 _dispatch_client_callout + 8
      20  libdispatch.dylib                   0x00007fff8b272723 _dispatch_barrier_sync_f_invoke + 39
      21  CoreData                            0x00007fff88cfc87c _perform + 172
      22  CoreData                            0x00007fff88cfc6c2 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 354
      23  CoreData                            0x00007fff88cb4309 -[NSManagedObjectContext executeFetchRequest:error:] + 537
      24  CoreData                            0x00007fff88d0481e -[NSFaultHandler retainedFulfillAggregateFaultForObject:andRelationship:withContext:] + 254
      25  CoreData                            0x00007fff88d7faa8 -[_NSFaultingMutableArray willRead] + 120
      26  CoreData                            0x00007fff88d7fe99 -[_NSFaultingMutableArray count] + 25
      27  CoreFoundation                      0x00007fff92b82e69 -[NSArray lastObject] + 25
      28  Scuttlebutt                         0x0000000100041aab -[BSMessageCellView setObjectValue:] + 283
      29  AppKit                              0x00007fff936ca006 -[NSTableRowData _addViewToRowView:atColumn:row:] + 696
      30  AppKit                              0x00007fff936c9b5f -[NSTableRowData _addViewsToRowView:atRow:] + 151
      31  AppKit                              0x00007fff936c80f5 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 415
      32  AppKit                              0x00007fff936c7e7a -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 272
      33  AppKit                              0x00007fff936c7149 -[NSTableRowData _unsafeUpdateVisibleRowEntries] + 740
      34  AppKit                              0x00007fff936c6ce1 -[NSTableRowData updateVisibleRowViews] + 119
      35  AppKit                              0x00007fff936da8b3 -[NSTableRowData _idleUpdateVisibleRows] + 66
      36  CoreFoundation                      0x00007fff92b5cdc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
      37  CoreFoundation                      0x00007fff92b5c8dd __CFRunLoopDoTimer + 557
      38  CoreFoundation                      0x00007fff92b420c9 __CFRunLoopRun + 1513
      39  CoreFoundation                      0x00007fff92b416e2 CFRunLoopRunSpecific + 290
      40  HIToolbox                           0x00007fff9427e0a4 RunCurrentEventLoopInMode + 209
      41  HIToolbox                           0x00007fff9427de42 ReceiveNextEventCommon + 356
      42  HIToolbox                           0x00007fff9427dcd3 BlockUntilNextEventMatchingListInMode + 62
      43  AppKit                              0x00007fff93544b13 _DPSNextEvent + 685
      44  AppKit                              0x00007fff935443d2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
      45  AppKit                              0x00007fff9353b773 -[NSApplication run] + 517
      46  AppKit                              0x00007fff934e01a6 NSApplicationMain + 869
      47  Scuttlebutt                         0x0000000100002225 main + 53
      48  Scuttlebutt                         0x00000001000021e4 start + 52
      49  ???                                 0x0000000000000003 0x0 + 3
  )
  </code></pre>
  
  <p>This is what came up when I tried dumping the offending object's details -- quite visible that it's an object ID instead of the object itself.</p>
  
  <pre><code>(lldb) expression (NSString*) [(id)0x10101b200 description]
  (NSString *) $0 = 0x0000000108b03880 @"0x10101b200 &lt;x-coredata://8F1FBB6B-505B-4169-A9D0-10D48CE5D4DC/YammerMessage/p101&gt;"
  (lldb) expression (Class) [(id)0x10101b200 class]
  (Class) $2 = _NSObjectID_48_0
  </code></pre>