From the course: iOS Development: Security
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Retrieve items from the Keychain - iOS Tutorial
From the course: iOS Development: Security
Retrieve items from the Keychain
- [Instructor] Adding items to the keychain is not really useful if we can't retrieve them. Let's add the missing feature to the keychainFacade class. I'll implement the new method. Let's call it string forKey. But first let me make some place here and I'm going to add a new public method called string forKey. Again the key argument is of type String and the method returns an optional String and it can also throw. Next let's perform the usual validation for the input key. Guard not key is empty else we throw an error of type KeychainFacadeError invalid content. The we set up the query dictionary. Again I'll be declaring a variable called queryDictionary and initialize it using setupQueryDictionary with our key. Oh let's fix this one. It's actually throws. We have to specify two more active routes for the search query. First I specify that I want the query to return the items data. The key in this case should be kSecReturnData. So queryDictionary with the key kSecReturnData and let's…
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
-
-
-
-
-