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.

Implementing a Keychain wrapper

Implementing a Keychain wrapper - iOS Tutorial

From the course: iOS Development: Security

Start my 1-month free trial

Implementing a Keychain wrapper

- [Instructor] We continue with the pasteboard demo app. We're going to replace the user default based storage and rely on the keychain instead. The keychain API consists of C functions that are a bit verbose, so developers usually end up building convenience wrappers around it. Another option is to use a third party facade like Swift keychain wrapper. Alright, now let's switch back to Xcode. We're going to build our own keychain wrapper. So let's create a new file. I call it Keychain Facade. We need to import the security framework. Then, I declare the Keychain Facade class. First I'm going to set up the query dictionary. This dictionary describes this item to be handled by one of the keychain service's functions. The dictionary has a similar structure for the functions we're going to implement. So to avoid code application, I extract the dictionary set up code to a private method. I'm going to call it Setup Query Dictionary. The method takes an argument called Key of type string…

Contents