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 339 forks source link

Syntax changes for next update. #61

Closed crashoverride777 closed 7 years ago

crashoverride777 commented 7 years ago

Thanks for the quick swift 3 update. Could you please do the following syntax changes for the next update to make it even more swift 3 like and closer to NSUserDefaults.

1) Change the singleton access to either default, standard or shared. So instead of

KeychainWrapper.defaultKeychainWrapper.set(...)

it reads

KeychainWrapper.default.set(...) or KeychainWrapper.standard.set(...) or KeychainWrapper.shared.set(...)

2) Change the remove method from

...remove(key: ....)

to

...removeObject(forKey: ...)

jrendel commented 7 years ago

Thanks for the suggestions. I went back and forth on what to do with remove, but I do like the idea of keeping it closer to NSUserDefaults and more consistent with the other functions.

The singleton access cleanup looks good too, I like keeping it more concise.

Everything else working for you ok? Between the unit test issues on iOS 10 simulator and CocoaPod submission problems, this update was less tested than I would have liked. But I also didn't want to delay it anymore.

crashoverride777 commented 7 years ago

Hey, thanks for the reply, big fan of your helper.

I have been reading through your helper and thats the 2 main things I noticed that are different from UserDefaults. If you do those changes you are basically identical.

I am not sure what singleton access you should use, I use "shared" for all my projects now (sharedInstance prior to swift 3). Apple also seems to now use "shared" for most singletons, e.g ReplayKit. UserDefaults uses "standard" and iCloud uses "default", so its really up to you what you prefer.

I have been using your helper since xCode 8 GM with my own changes to make it work with Swift 3. I haven't had any problems at all so far.

I just updated to your official version and everything seems fine too, I will report back incase I find something.

Thanks again for your continued support.

crashoverride777 commented 7 years ago

Oh yeah I opened another issue but it would be so awesome if you could provide cocoa pods support for tvOS. All my projects are iOS and tvOS universal and its a bit of a hassle without the cocoa pods support for tvOS. Is that much work for you to do? I have been using your helper for at least 8 months on tvOS and it works flawlessly.

jrendel commented 7 years ago

I've update the syntax as suggested. I went with .standard for singleton access to keep consistent with UserDefaults. These are in version 2.2.1, which I'm pushing to CocoaPods now.

As for tvOS support, I will get to that eventually. I've also got requests for watchOS support and macOS support, so I need to go through them all one by one and see what is required. I think tvOS and watchOS are relatively simple.

crashoverride777 commented 7 years ago

Hey, thanks for the update.

In regarde to tvOS, there is literally nothing you have to do. I have been using your helper on tvOS for over 1 year and never had a problem. Would be great if you can get cocoa pods support. I am not sure about watchOS as I dont have an apple watch.