I would like to know how to fetch unique field values (song_type) from core data.
i have the below code for that
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Songs" inManagedObjectContext:myManagedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]init];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObject:@"song_type"]];
[fetchRequest setEntity:entity];
NSError *aError;
NSMutableArray *fetchedResultsArray = [[myManagedObjectContext executeFetchRequest:fetchRequest error:&aError]mutableCopy];
if(! fetchedResultsArray ){
NSLog(@"EEEERRROR");
}
else {
NSLog(@"fetched %d", [fetchedResultsArray count]);
}
[fetchedResultsArray release];
[fetchRequest release];
i am getting the below error
Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason: ‘Invalid keypath song_type
passed to setPropertiesToFetch:’
Set following 2 properties and you are done.
Hope this helps.
EDIT