Search code examples
iphoneioscore-dataios5nsfetchrequest

Selecting a single field in a fetch into an array to load a picker


trying to load a single field into an array and then loading that in a picker. I think its in the creation of the array that I have a problem.

This is my code:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescr];
[request setPropertiesToFetch:[NSArray arrayWithObject:@"name"]];

NSError *error;
NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];
self.pickerData = array;

The error I get is this:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject isEqualToString:]: unrecognized selector sent to instance 0x7bb8100'

Any help would be appreciated...


Solution

  • Please go through the documentation of NSManaged Object- http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html

    Then fetch the data properly and pass to Picker. Main issue is wrong kind of comparison of objects, due to which app is crashing.