I would like to pass a parameter into my delegate to determine to continue or check for cert.
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
NSLog(@"Parameter 1 %@", parameter);
}
NSURLSessionDataTask * dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if ([data length]>0 && error == nil) {
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSLog(@"%@", json);
resolve(json);
} else if ([data length]==0 && error ==nil) {
NSError *error = [NSError errorWithDomain:@"xxxx" code:400 userInfo:@{@"Error reason": @"No data returned."}];
reject(@"error", @"error description", error);
} else if( error!=nil) {
NSError *error = [NSError errorWithDomain:@"xxxx" code:400 userInfo:@{@"Error reason": @"Invalid request."}];
reject(@"error", @"error description", error);
}
}];
// Start The Task
[dataTask resume];
How can I pass a parameter from my URLSession into this delegate. I looked for a few hours and found nothing online about this. No surprise. Most Obj-c things I find no good references or examples or walkthroughs. Everything is extracted.