Last active
September 26, 2016 06:32
-
-
Save mattjgalloway/6b46ae89f6603cdd64c49f38e07221b5 to your computer and use it in GitHub Desktop.
WTF Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I have a URL and a UUID stored in UserDefaults, both as String. | |
* I want to extract both and convert the UUID string into an actual UUID. | |
* Here is something strange... | |
*/ | |
// This works on iOS. But on watchOS, the guard returns, even though the URL and UUID exist in UserDefaults | |
guard | |
let accountURL = UserDefaults.standard.string(forKey: UserDefaultKeys.accountURL.rawValue), | |
let accountUUIDString = UserDefaults.standard.string(forKey: UserDefaultKeys.accountUUID.rawValue), | |
let accountUUID = UUID(uuidString: accountUUIDString), | |
else { return } | |
// However, in the following, on watchOS, the guard does pass. | |
guard | |
let accountURL = UserDefaults.standard.string(forKey: UserDefaultKeys.accountURL.rawValue), | |
1 == 1, | |
let accountUUIDString = UserDefaults.standard.string(forKey: UserDefaultKeys.accountUUID.rawValue), | |
1 == 1, | |
let accountUUID = UUID(uuidString: accountUUIDString), | |
1 == 1 | |
else { return } | |
// WAT!?!!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment