我有一个嵌套字典数据的数组,如下所示:
[{ link : [
{ $ref: "foo", $href: "first_foo"},
{ $ref: "bar", $href: "barrrrrrr"},
{ $ref: "quz", $href: "quzzzzzzz"}]},
{ link : [
{ $ref: "foo", $href: "second_foo"},
{ $ref: "bar", $href: "barrrrrrr"},
{ $ref: "quz", $href: "quzzzzzzz"}]}]
我想从foo
每本词典中挑选出来。想要的结果是这样的:
[{ foo: "first_foo"}, { foo: "second_foo"}]
我已经尝试使用[myArray valueForKey @"@customFilterForFoo"]
,并在 NSDictionary 上实现了customFilterForFoo
for 类别,但这最终得到*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSCFArray 0x6b81a10> valueForUndefinedKey:]: this class is not key value coding-compliant for the key customFilterForFoo.'
我怎么能做这样的事情?谢谢!