Search code examples
iosobjective-cplist

Objective-c: Making NSArray all lowercased


i am having a strange problem when tryin to catch some data on my plist.. so, here is my plist plist

so okay, getting the data is fine, so then i used this code to just you know get the data

NSString *path = [[NSBundle mainBundle] pathForResource:@"kurdiebg" ofType:@"plist"];
NSArray *plistData = [NSArray arrayWithContentsOfFile:path];

NSPredicate *filter = [NSPredicate predicateWithFormat:@"english = %@", self.searchQwery.text];
NSArray *filtered = [plistData filteredArrayUsingPredicate:filter];



NSLog(@"found matches: %@ : %@", filtered,[filtered valueForKey:@"kurdi"]);

if (filtered.count>0) {
    NSDictionary *dic  = filtered[0];
    self.ss.text = dic[@"kurdi"];
}

but here to the strange part-- when i try to search for abbey (lowercased)it returns the right result, the problem is it has twenty two thousand records they're not all lowercased, Abbey

okay, then when i make the first A capital, it returns nothing abbey

Thanks for even visiting


Solution

  • You can do case insensitive search by adding [c]. Try this.

    NSPredicate *filter = [NSPredicate predicateWithFormat:@"english ==[c] %@", self.searchQwery.text];