0
I am creating a Uitableview to load the bookmarks that are saved in Nsuserdefaults, the values are the Ids. ex. 34, 45, 55...
I am creating the url and passing parameter through a Nsmutablearray. (34, 45, 55). as follows.
NSString * porGeral = [NSString stringWithFormat:@"http://.../api/listarFavoritos.php?listaCli=%@", @"34, 45, 55"];
url = [NSURL URLWithString:porGeral];
NSLog(@"%@", porGeral);
NSURLSession * session = [NSURLSession sharedSession];
NSURLSessionDownloadTask * task =
[session downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
NSData * jsonData = [[NSData alloc] initWithContentsOfURL:location];
news = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"%@", news);
[self.tableView reloadData];
[self.progressView removeFromSuperview];
});
}];
[task resume];
}
The error:
*** Terminating app due to uncaught Exception 'Nsinvalidargumentexception', Ason: 'data Parameter is nil'
If I pass this way the url in the browser does not present the error, then I managed to identify that this error is in Nsurlsessiondownloadtask.
Any suggestion?
was worth to all.
Opa Rafael thanks for the tips, now that I saw what I’m doing with downloadTaskWithURL was using in another application that actually downloads. thanks for the tip.
– Fabricio Aguiar