Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering data with changeable key by it's value

I'm currently working on a project where I get JSON responce which looks this way:

{"1":"qwerttt","2":"asdasda"}

I'm using Objective-c. I know how to filter data with the predicate knowing the key name. It could look like this:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"city contains[c] %@", searchText];

But I don't understand what should I write in this case when the key name is not the same for each pair. Should I write my own filter, create a special dictionary or array in a comfortable format or do something else?Any help would be appreciated.

Updated: This is what I get when I parse json

enter image description here

like image 638
AOY Avatar asked Nov 20 '25 15:11

AOY


1 Answers

Try something like this:

[[_regions allValues] filteredArrayUsingPredicate:
                     [NSPredicate predicateWithFormat:@"SELF CONTAINS[c] %@",
                                  "RegionImSearchingFor"]];
like image 191
TMob Avatar answered Nov 23 '25 03:11

TMob