Get all values in a JSON dictionary, without accessing by key
JSON Example:开发者_StackOverflow中文版
[{
"title1":"Hey",
"title2":"Hoh",
"title3":"Hah",
"title4":"Hoo"
}]
How can I get value (hey,hoh,hah,hoo) without using valueForKey?
Could anyone guide me please?
--------------Edit--------------
I use JSON-Framework. And Now I use NSDictionary *jsonDict = [string JSONValue];
Assuming you have your data in an NSDictionary, try allValues.
Remember however than an NSDictionary is unsorted, so the order of the values is undefined.
As Todd already said, NSDictionary has a method allValues - check the NSDictionary Documentation
An example of looping through the value's is
for(NSString *value in [jsonDict allValues]){
NSLog(@"Found Value %@",value);
}
Again, these values will be unsorted as they are coming from a dictionary.
加载中,请稍侯......
精彩评论