Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func ResetNSURLCredentials() {
- let dictAllCredentials : NSDictionary = NSURLCredentialStorage.sharedCredentialStorage().allCredentials
- let protectionSpace : NSURLProtectionSpace = NSURLProtectionSpace(host: "xyz.com", port: 0, `protocol`: "http", realm: nil, authenticationMethod: nil)
- //let tempDictionary : NSDictionary = NSURLCredentialStorage.sharedCredentialStorage().credentialsForProtectionSpace(protectionSpace)
- if(dictAllCredentials.count > 0 ){
- var protectionSpaceEnumerator=dictAllCredentials.keyEnumerator() as NSEnumerator
- var urlProtectionSpace : AnyObject?
- while(urlProtectionSpace as NSEnumerator == protectionSpaceEnumerator.nextObject() as NSEnumerator){
- var userNameEnumerator : NSEnumerator = dictAllCredentials.objectForKey(urlProtectionSpace).keyEnumerator()
- var userName : NSEnumerator = NSEnumerator()
- while(userName == userNameEnumerator.nextObject() as NSEnumerator){
- var credential : NSURLCredential = dictAllCredentials.objectForKey(urlProtectionSpace).objectForKey(userName) as NSURLCredential
- NSURLCredentialStorage.sharedCredentialStorage().removeCredential(credential, forProtectionSpace: protectionSpace)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment