Open thisisjeffwong opened 3 years ago
@thisisjeffwong very good point, if you access Keychain from different threads, then it's better to use single instance
let keychain = KeychainSwift()
...
keychain.set("Hello world", forKey: "my key")
instead of
KeychainSwift().set("Hello world", forKey: "my key")
I've removed the KeychainSwift().set()
example the readme. Well-spotted. 👍
I notice in each example in the main readme that a new
KeychainSwift()
is instantiated before use. This could be interpreted to mean each use of the keychain should instantiate aKeychainSwift
object before use.However, I notice there is a private
NSLock
in each instance and the lock is acquired before getting or setting. This would imply that there should only be one instance accessed in your app. Otherwise, the locks are meaningless since they are not a single lock across all instances.Is it a mistake to instantiate one of these at each get and set?