Guest User

Untitled

a guest
Sep 1st, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. func ResetNSURLCredentials() {
  2.  
  3. let dictAllCredentials : NSDictionary = NSURLCredentialStorage.sharedCredentialStorage().allCredentials
  4. let protectionSpace : NSURLProtectionSpace = NSURLProtectionSpace(host: "xyz.com", port: 0, `protocol`: "http", realm: nil, authenticationMethod: nil)
  5. //let tempDictionary : NSDictionary = NSURLCredentialStorage.sharedCredentialStorage().credentialsForProtectionSpace(protectionSpace)
  6.  
  7. if(dictAllCredentials.count > 0 ){
  8.  
  9. var protectionSpaceEnumerator=dictAllCredentials.keyEnumerator() as NSEnumerator
  10. var urlProtectionSpace : AnyObject?
  11.  
  12. while(urlProtectionSpace as NSEnumerator == protectionSpaceEnumerator.nextObject() as NSEnumerator){
  13.  
  14. var userNameEnumerator : NSEnumerator = dictAllCredentials.objectForKey(urlProtectionSpace).keyEnumerator()
  15. var userName : NSEnumerator = NSEnumerator()
  16.  
  17. while(userName == userNameEnumerator.nextObject() as NSEnumerator){
  18.  
  19. var credential : NSURLCredential = dictAllCredentials.objectForKey(urlProtectionSpace).objectForKey(userName) as NSURLCredential
  20. NSURLCredentialStorage.sharedCredentialStorage().removeCredential(credential, forProtectionSpace: protectionSpace)
  21.  
  22.  
  23. }
  24.  
  25. }
  26.  
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment