开发者

Is there an Library to support NSDictionary travelling in objective-c

Background:

After parsing json data to NSDictionary or NSArray, the expression is extremely long when you want to reach a deep attribute or value. For example:

[[[book objectForKey:@"author"] objectForKey@"contact"] objectForKey:@"mobile"]
[[[[book objectForKey:@"author"] objectAtIndex:0] objectForKey"@"contact"] obj开发者_JAVA技巧ectForKey:@"mobile"]

Is there a tool to facilitate this use a query expression like "/author/contact/mobile" or "/author/[0]/contact/mobile" and used as [SimpleTraveller getValueFromDic:book, @"/author/contact/mobile"]?


Try

id obj = [book valueForKeyPath:@"author.contact.mobile"];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜