您好我正在尝试按需加载数据。第一次加载数据后,我调用以下方法。
-(void)carregaDados2
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSURL *url2 = [[NSURL alloc] initWithString:[@"http://localhost:3000/json.aspx?ind=12&tot=12" stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:url2];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSError *jsonParsingError = nil;
NSMutableData *data2;
data2 = [[NSMutableData alloc] init];
[data2 appendData:response];
NSMutableData *dt = [[NSMutableData alloc] init];
[dt appendData:data];
[dt appendData:data2];
news = [NSJSONSerialization JSONObjectWithData:dt options:nil error:nil];
[tableViewjson reloadData];
NSLog(@"Erro: %@", jsonParsingError);
}
但是我的表格视图是空白的。
我究竟做错了什么?
我真的不知道还能做什么。
现在我改变了我的代码,我不能把我的第二个索引 NSMutableArray 放在我的 UITableView
-(void)carregaDados2
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSURL *url2 = [[NSURL alloc] initWithString:[@"http://localhost:3000/json.aspx?ind=12&tot=12" stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding]];
NSURLRequest *request = [NSURLRequest requestWithURL:url2];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSError *jsonParsingError = nil;
NSMutableData *myData = [[NSMutableData alloc]init];
[myData appendData:response];
NSMutableArray *news2;
news2 = [NSJSONSerialization JSONObjectWithData:myData options:nil error:&jsonParsingError];
NSLog(@"LOG: %@", news2);
}