jrendel / SwiftKeychainWrapper

A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift.
MIT License
1.59k stars 340 forks source link

removeObjectForKey and removeAllKeys always returns false #53

Closed speaktoalvin closed 8 years ago

speaktoalvin commented 8 years ago

When I open the app, In App Delegate I can see that there is a value in Keychain and KeychainWrapper is successfully fetching it.

But when I try to remove it [ Using that specific key ] it always return false. So I tried removeAllKeys method that also returns nil. I have tried re-booting my system, tried in different computers. Don't know what's happening in here.

It's a Cocoa App. Deployment Target : 10.10

 if let _ = KeychainWrapper.defaultKeychainWrapper().stringForKey(UserDefaults.TokenSet_Secret.rawValue)
        {
            // Always here - Value is there
        }
        else
        {
            // 
        }

let success = KeychainWrapper.defaultKeychainWrapper().removeObjectForKey(UserDefaults.TokenSet_Secret.rawValue)

        if success {

            // Dismiss

            self.delegate?.clickedOnDismiss()
            dismissController(self)
        }
        else {

           //  Always comes here :(

            // Show Alert

            self.presentAlertController(UserConstants.alertTitle_Oops, message: UserConstants.WritingTweets.CoultNotGetToken.rawValue)
        }

Please guide me, and let me know if I miss anything.

jrendel commented 8 years ago

I've tested this in the latest Swift 3 version of the library and it is working as expected. I added examples of how to use them in the example app and you can see the specific commit here:

https://github.com/jrendel/SwiftKeychainWrapperExample/commit/a6c4a4df86d6316a73af3ce0027828cff81e2526