1
我想檢查結果的JSON爲空或不是..我用這個代碼如何檢查值是來自json是否爲空?
- (NSString *)likesCount {
if ([facebook valueForKey:@"likes"] == [NSNull null]) {
return @"";
}
else {
return [facebook valueForKey:@"likes"];
}
}
likes = 1
;如果它存在並且爲空"like"
在輸出中不可見但是如果它不存在那麼它將返回(null)
..我使用上面的代碼但它不起作用。
我打印喜歡的這個值的UITableViewCell
UILabel *commentLike = [[UILabel alloc] initWithFrame:CGRectMake(200, 70, 100, 20)];
commentLike.font = [UIFont fontWithName:@"Arial" size:10.0];
NSString *commentLikeString = [NSString stringWithFormat:@"%@ ",[(Facebook *)[tableArray objectAtIndex:indexPath.row]likesCount]];
commentLike.text = [NSString stringWithFormat:@"%@ Person"];
[cell.contentView addSubview:commentLike];
感謝
它正在崩潰我的應用程序 – DeviPhone26