I have NSArray *listArray with objects like - (id, name).
I would like sort array by (name) -
NSString *alphabet = [agencyIndex objectAtIndex:indexPath.section];
//---get all states beginning with the letter---
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
NSMutableArray *listSimpl = [[NSMutableArray alloc] init];
for (int i=0; i<[[Database sharedDatabase].agents count]; i++) {
Town *_town = [[Database sharedDatabase].agents objectAtIndex:i];
[listSimpl addObject:_town];
}
NSArray *states = [listSimpl filteredArrayUsingPredicate:predicate];
But error - "Can't do a substring operation with something that isn't a string (lhs = <1, Arrow> rhs = A)"
How can i do this? I would like to filter Array with object by first letter in (name)- "A"