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 an NSMutableArray. (34, 45, 55). this way.
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 Displayed:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
Your I pass this way the url in the browser does not display the error, so I could identify that this error is in the NSURLSessionDownloadTask.
Any suggestions?
Thanks everyone.