我的应用程序中有一个JSON解析器,我将值加载到一个detailDataSourceDict变量中。当我尝试获取数组的valueForKey并尝试将其与0进行比较时,它永远不会工作...
下面是我的代码:
if (indexPath.row == 1) {
NSNumber *rating = [detailDataSourceDict valueForKey:@"rating"];
NSLog(@"Rating: %@",rating);
if (rating == 0) {
cell.detailTextLabel.text = @"This sheet has not yet been rated.";
}
else {
cell.detailTextLabel.text = [NSString stringWithFormat:@"This sheet has a %@ star rating.",rating];
}
cell.textLabel.text = @"Rating";
}我在我的JSON提要中看到" rating ":" 0 ",但是当rating为0时,它显示"This sheet has a 0 star rating.",而不是"This sheet not been“。
有什么建议吗?谢谢。
https://stackoverflow.com/questions/13432042
复制相似问题