按键路径修改NSMutableDictionary

时间:2016-01-24 09:35:50

标签: ios objective-c plist kvc

我有NSDictionary嵌套NSDictionary/NSArray(通过JSON生成)。

我需要根据强加给我的一些逻辑删除多个地方的对象。

例如,假设字典有一些结构,如:

{
   "Array1" : [
      {
          "InnerArray1" : [ 
               {
                   "some conditional field" : Evaluate this ...
               }
           ],
          "More Properties : ....
      }
   ],
   "Array2" : {
       ... some complex inner structure
                  {
                      // some inner object to remove according to "evaluate condition"
                  }
   }

}

当我迭代“Array1.InnerArray1...”并将某些条件评估为true时,我需要删除不相交位置的对象。

理想情况下,我可以做类似

的事情
foreach item in Array1.InnerArray1 {
   if item evaluates to true {
      // evaluate the disjoint location...
         remove Array2.....InnerObject(s) where ConditionField == true
   }
}

目前,迭代内部对象并在同一个传递中改变它们非常尴尬(并且很难阅读)。

鉴于我已经创建了整个数据树的深度可变副本,是否可以使用kvc或其他机制删除嵌套对象而不进行嵌套迭代?

0 个答案:

没有答案