Tid*_*ane 3 iphone objective-c ios sbjson
我在将数据插入tableView中的单元格时遇到问题.当我搜索错误源时,我看到我的webservice正在返回null值.因此,当我将名称调用到单元格时,它会崩溃参数为null.因此,原因是数据库问题,我只想跳过添加例如:{"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;
}
Run Code Online (Sandbox Code Playgroud)
我只想在这里解析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];
}
Run Code Online (Sandbox Code Playgroud)
Cyr*_*lle 12
您可以通过在循环中执行此操作来测试对象是否为null:
if ([taxi isKindOfClass:[NSNull class]])
continue;
//else, process it
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7679 次 |
| 最近记录: |