ios - Getting Dictionary Keys for the Filtered Values -
i having nsmutabledictionary (subjectvalue) contains value , keys. want filter based on values searched in search bar. so, used code below.
nsarray *allvalues = [subjectvalue allvalues]; nsarray *filteredvalues = [allvalues filteredarrayusingpredicate:predicate];
now, filteredvalues have values based on search word.
now, want keys filtered values got above result. know how values , all, want keys filtered result.
please advise how can that?
this not duplicate of question. existing query link
what has been asked in above link is, how retrieve values based on predicate search. i'm asking beyond that. have got filtered values, want keys filtered values. question different.
there function keysofentriespassingtest in nsdictionary. looking for? example:
nsdictionary *subjectvalue = @{@"1":@"a", @"2":@"b", @"3":@"c", @"4":@"d"}; nsarray *filteredvalues = @[@"b", @"d"]; nsset *keys = [subjectvalue keysofentriespassingtest:^bool(id key, id obj, bool *stop) { return [filteredvalues containsobject:obj]; }]; nslog(@"%@", keys.description);
the output {(4,2)} (nsset)
Comments
Post a Comment