Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with accessing attributes of relationship after fetching with setPropertiesToFetch
    primarykey
    data
    text
    <p>I'm only fetching some attributes and a 1-to-1 relationship of an entity using -setPropertiesToFetch and result type set to NSDictionaryResultType. Now I have a problem accessing the attributes of the returned relationship. As soon as I want to access a property I get an NSInvalidArgumentException', reason: unrecognized selector sent to instance</p> <p>Here is the full Exception:</p> <pre><code>2011-03-23 11:02:10.435 ThurboApp[32996:207] -[_NSObjectID_48_0 lon]: unrecognized selector sent to instance 0x5a3f490 2011-03-23 11:02:10.441 ThurboApp[32996:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSObjectID_48_0 lon]: unrecognized selector sent to instance 0x5a3f490' </code></pre> <p>Here is the corresponding source code:</p> <pre><code> - (void)fetchAllPois { NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"POI" inManagedObjectContext:self.managedObjectContext]; request.entity = entity; [request setResultType:NSDictionaryResultType]; [request setPropertiesToFetch:[NSArray arrayWithObjects:@"poiId",@"categoryId",@"poiTitle",@"coordinates", nil]]; request.sortDescriptors = nil; request.predicate = nil; NSError *error = nil; self.fetchResult = [self.managedObjectContext executeFetchRequest:request error:&amp;error]; } - (MapPoint *)createMapPointFromDictionary:(NSDictionary *)dict { NSString *poiId = [dict objectForKey:@"poiId"]; NSString *title = [dict objectForKey:@"poiTitle"]; Coordinates *coords = (Coordinates *)[dict objectForKey:@"coordinates"]; NSNumber *category = [dict objectForKey:@"categoryId"]; CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake([coords.lat doubleValue], [coords.lon doubleValue]); //here raises the exception MapPoint *p = [[[MapPoint alloc] initWithPoiId:poiId title:title category:[category intValue] coordinates:coordinates] autorelease]; return p; } </code></pre> <p>interface for Coordinates:</p> <pre><code>@interface Coordinates : NSManagedObject { } @property (nonatomic, retain) NSNumber * lat; @property (nonatomic, retain) NSNumber * alt; @property (nonatomic, retain) NSNumber * lon; @property (nonatomic, retain) NSManagedObject * poi; @end </code></pre> <p>I've already checked, that the values returned in the dictionaries are correct. Even coordinates points to a Coordinate object.</p> <p>Help is much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload