Guest User

Untitled

a guest
Aug 9th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. iOS 5 - connect to an HTTPS server
  2. - (void)setCredential:(NSURLCredential *)credential forProtectionSpace:(NSURLProtectionSpace *)protectionSpace
  3.  
  4. - (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:
  5. (NSURLAuthenticationChallenge *)challenge {
  6.  
  7. if ([challenge previousFailureCount] <= maxRetryCount ) {
  8. NSURLCredential *newCredential =
  9. [NSURLCredential
  10. credentialWithUser: userName
  11. password:password
  12. persistence:NSURLCredentialPersistenceForSession];
  13.  
  14. [[challenge sender]
  15. useCredential:newCredential
  16. forAuthenticationChallenge:challenge];
  17.  
  18. }
  19. else
  20. {
  21. NSLog(@"Failure count %d",[challenge previousFailureCount]);
  22. }
  23. }
Add Comment
Please, Sign In to add comment