我尝试使用下面的代码将 Json 解析数据与表视图绑定并获取异常。我也在使用 ASIHttpRequest 和 Json。
**Error details:**
webservice[2864:f803]
***
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[testViewController tableView:numberOfRowsInSection:]:
unrecognized selector sent to instance 0x6ecc4e0'
***
NSString *responseString = [request responseString];
SBJsonParser *parser=[[SBJsonParser alloc]init];
NSDictionary *obj=[[NSDictionary alloc]init];
obj=[parser objectWithString:responseString error:nil];
return obj.count;
NSString *responseString = [request responseString];
SBJsonParser *parser=[[SBJsonParser alloc]init];
NSDictionary *obj=[[NSDictionary alloc]init];
obj=[parser objectWithString:responseString error:nil];
NSMutableArray *statuses = [[NSMutableArray alloc]init];
for (NSDictionary *status in obj)
{
[statuses addObject:status];
}
self.listdata=statuses;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"myCell"];
if (cell == nil) {
cell = [[ UITableViewCell alloc ] initWithFrame:CGRectZero];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [listdata objectAtIndex:row];
return cell;