如何从 JSON 字典中提取单个评级值?评级值仅驻留在父 JSON 字典中(它不是嵌套的)。我的代码在这里:
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];
for (NSDictionary *diction in allDataDictionary)
{
NSString *rating = [diction objectForKey:@"rating"];
[array addObject:rating];
}
[[self myTableView] reloadData];
}
其次,我如何制作一个 If 语句来将评级值转换为一个NSString
,以便它出现在 iPhone 模拟器上?