标签:
当面向字典开发或服务器返回的数据为字典时,应当判断字典内是否有对应的key值,从而避免返回key值为空而导致程序奔溃:
NSDictionary *dict = self.datas[indexPath.row]; if([[dict allKeys] containsObject:@"key"]) { cell.textLabel.text = [dict valueForKey:@"ke y"]; } else { cell.textLabel.text = @"没有对应的key值"; }
标签:
原文地址:http://www.cnblogs.com/happyplane/p/4783079.html