こんにちは、オンデマンドでデータを読み込もうとしています。データが初めてロードされた後、次のメソッドを呼び出します。
-(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);
}
しかし、私のテーブルビューは空白です。
私は何を間違っていますか?
他に何をすべきか本当にわかりません。
コードを変更したので、UITableView に NSMutableArray の 2 番目のインデックスを配置できません
-(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);
}