From the course: iOS Development: Security
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Removing items from the Keychain - iOS Tutorial
From the course: iOS Development: Security
Removing items from the Keychain
- [Instructor] We can avoid the duplicate item error upon adding an item to the key chain by removing it if it already exists. So, let's add a new method through the key chain facade class. I'm going to switch to our key chain facade file. Let's make some place here and let's add a new method called remove string. I'm going to make it public too. The method has a single argument of type string. This is the unique identifier of the item we want to delete from the key chain. I mark the method as throw able since removing an item from the key chain might fail for various reasons. Let me scroll up a bit. Next, we'll validate the key. I'm going to use the guard statement. The key shouldn't be empty. As I print a warning message and throw a key chain facade error. The message is key must be valid and I throw an error of type invalid content. If everything goes well and our key is valid we can use the set item delete function to delete the item. This function takes a query dictionary with…
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
-
-
-
-
-