How to use HTTPS with NSURLConnection?
-
06-09-2019 - |
Question
I'm interested in HTTPS with NSURLConnection
. Is it possible to send a request, respond to a challenge and load the secure URL?
Is there anything else that can be done with NSURLConnection
via HTTPS?
Solution
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://monsite/mapage.php"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[[NSString stringWithFormat:@"score=222"] dataUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
and then implement the appropiate delegate methods for NSURLConnection.
OTHER TIPS
NSUrlConnection works out of the box with HTTPS. You do not have to do anything special.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow