From the course: iOS Development: Security
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Using the Keychain wrapper - iOS Tutorial
From the course: iOS Development: Security
Using the Keychain wrapper
- [Instructor] We have now have a keychain wrapper class that can be used to securely store a string in the keychain. So let's use it. I switch back to our view controller file and I define a lazy variable called keychain. Keychain... and I initialize it using the keychain facade initializer. Next we refactor the unsafe credentials method that uses the insecure user default to store the username and the password. So let's get rid of this code first. Instead, we're going to use the keychain set string for key to persist the username and the password in the keychain. Since this method throws, we need to call it using try from within a do catch block. First, let's add the username. I need to call the method using try and keychain dot set. The string should be the username for key user name. And now let's also set the password. Also here, we use try, keychain dot set, the string should be the password for key password. We need to handle the errors that might be thrown. First, I'll handle…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Keychain overview1m
-
(Locked)
Implementing a Keychain wrapper3m 3s
-
(Locked)
Adding a value to the Keychain5m 9s
-
(Locked)
Using the Keychain wrapper4m 31s
-
(Locked)
Removing items from the Keychain3m 30s
-
(Locked)
Retrieve items from the Keychain4m 33s
-
(Locked)
Restore values from the Keychain2m 19s
-
-
-
-
-