objective c - Filter and NSDictionary of NSArray of NSDictionary's -


i have nsdictionary contains 150 keys of boiler manufacturers. value each key nsarray of nsdictionary. each nsdictionary represents boiler properties:

nsdictionary boilerdata = {      @"alpha" = [{name: boiler1, rating: 80}, {name:boiler2, rating: 90}],      @"beta" = [{name: boiler3, rating: 80}, {name:boiler4, rating: 91}, {name:boiler5, rating: 78}],      ... } 

i able filter boiler's have rating of 80. know need nspredicate, can't figure out how build it? none of other articles i've found seem fit requirement.

nsdictionary *boilerdata = @{   @"alpha" : @[@{@"name": @"boiler1", @"rating": @80}, @{@"name": @"boiler2", @"rating": @90}],   @"beta" : @[@{@"name": @"boiler3", @"rating": @98}, @{@"name": @"boiler4", @"rating": @80}, @{@"name": @"boiler5", @"rating": @90}]   };  nsmutablearray *filteredarray = [[nsmutablearray alloc] init]; nspredicate *predicate = [nspredicate predicatewithformat:@"rating = 80"]; (nsarray *array in [boilerdata allvalues]) {     [filteredarray addobjectsfromarray:[array filteredarrayusingpredicate:predicate]]; } nslog(@"all boilers rating = 80 : %@", filteredarray); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -