I have an app where I'm currently using the SwiftKeychainWrapper. Below is the code I have which checks if retrievedString
is nil
. However I'm still getting retrievedString: nil
in the console.
Shouldn't the code in the if-let statement not run, or am I using/understanding if-let incorrectly?
With the given example, what's the correct way to use if-let to unwrap my optional value?
if let retrievedString: String? = KeychainWrapper.stringForKey("username") {
print("retrievedString: \(retrievedString)")
//value not nil
} else {
//Value is nil
}