Comment utiliser HTTPS avec NSURLConnection?
-
06-09-2019 - |
Question
Je suis intéressé par HTTPS avec NSURLConnection
. Est-il possible d'envoyer une demande, répondre à un défi et charger l'URL sécurisée?
Y at-il autre chose qui peut être fait avec NSURLConnection
via HTTPS?
La 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.
Autres conseils
NSUrlConnection works out of the box with HTTPS. You do not have to do anything special.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow