Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test has function on simulator iOS10.3.1 always true #28

Open
luffyjie opened this issue Jul 15, 2020 · 0 comments
Open

Test has function on simulator iOS10.3.1 always true #28

luffyjie opened this issue Jul 15, 2020 · 0 comments

Comments

@luffyjie
Copy link

First thanks for sharing this useful frame.

My problem is when I use Xcode 11.5 simulator iOS 10.3.1 test Defaults.shared.has(.userIdKey) function (.userIdKey is String type) after I use clear the value, it's always return true. But when I use Defaults.shared.get(for: .userIdKey) is nil.

So I debug has function source code "po userDefaults.value(forKey: key._key)" is ▿ Optional

  • some : <62706c69 73743030 d4010203 04050608 09582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0a1 0755246e 756c6c5f 100f4e53 4b657965 64417263 68697665 72d10a0b 54726f6f 74800008 111a232d 3237393f 51545900 00000000 00010100 00000000 00000c00 00000000 00000000 00000000 00005b>

(lldb) po userDefaults.object(forKey: key._key)
▿ Optional

  • some : <62706c69 73743030 d4010203 04050608 09582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0a1 0755246e 756c6c5f 100f4e53 4b657965 64417263 68697665 72d10a0b 54726f6f 74800008 111a232d 3237393f 51545900 00000000 00010100 00000000 00000c00 00000000 00000000 00000000 00005b>

I test same code on iOS 11.4, iOS12, iOS13 on simulator are all correct.

I don't know what's make this issue. I have no real machine with version 10.3.1 to test it.

At last I use userDefaults.string(forKey: key._key) test it is correct, It seems userDefaults.value have problem on iOS 10.3.1 version.

May be public func has(_ key: Key) we can get value type first, then use match function get value is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant