我在向 tableView 中的单元格插入数据时遇到问题。当我搜索错误源时,我看到我的 web 服务正在返回空值。因此,当我将名称调用到单元格时,它会崩溃为空的参数。所以,原因是数据库问题,我只想跳过添加例如:{“name”:“null”}
在其他服务中,我将空值设为空......所以它不会引起问题......我认为它是作为字符串的空值。
这是一个例子:
{
"24_7" = 0;
address = "avenue innsbruck";
city = GRENOBLE;
country = FR;
dst = "14007.2046741012";
"h_saturday" = " - ";
"h_sunday" = " - ";
"h_week" = " - ";
id = 324;
"location_lat" = "45.154";
"location_long" = "5.73387";
name = "<null>";
"tel_1" = 0476544254;
"tel_2" = "";
zipcode = 38000;
}
当我在这里解析 json 时,我只想跳过添加这个。
NSString *theJSON = [request responseString];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *jsonDictionary = [parser objectWithString:theJSON error:nil];
//NSLog(@"OkRequest || %@ ", jsonDictionary);
[_jsonStation removeAllObjects];
for (NSDictionary *taxi in jsonDictionary)
{
[_jsonStation addObject:taxi];
}