In CoreData Model I have"customers" entity with follow columns: custostomer_id , name , city , phone
It has the follow data in it:
1 Mary Los-Angeles 054-112233
2 John New-York 054-334455
3 Anna Los-Angeles 054-445566
How can I get the List of all cities of customers where each city appears only once. For above example it should be {Los-Angeles, New-Yoirk}.
This is my code:
AppDelegate * delegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *context = delegate.managedObjectContext ;
NSEntityDescription *entityDescN = [NSEntityDescription entityForName:@"customers" inManagedObjectContext:context];
NSFetchRequest *requestN = [[NSFetchRequest alloc] init];
[requestN setEntity:entityDescN ];
NSPredicate *predN = [NSPredicate predicateWithFormat:@"?????????????"];
[requestN setPredicate:predN];
NSArray * objectsN = [context executeFetchRequest: requestN error:&error];
I mean what should be instead of "???" in NSPredicate definition? I tried to write this code also with NSExpression, but still didn't succeeded.