Filtering NSDictionary with predicate

前端 未结 4 1747
一生所求
一生所求 2020-12-13 15:31

I am using a NSDictionary that itself contains dictionaries some keys and its values.The format is like ,

{

\"1\" = {
        \"key1\" = \"ss\",
          \         


        
4条回答
  •  悲&欢浪女
    2020-12-13 16:08

    You can use keysOfEntriesPassingTest method of NSDictionary.

    Eg.

    NSSet *keys = [dict keysOfEntriesPassingTest:^BOOL(id  _Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {
    NSDictionary *object =(obj); 
    return ([@"tt" isEqualToString:object[@"key1] &&[@"vv"isEqualToString:object[@"key2"]);
    }];
    

    Reference : Apple Doc

提交回复
热议问题