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

Retrieve items from the Keychain - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

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…

Contents