Learn about how to create a query for searching for and retrieving data. Fetching the right data is important to avoid the wrong data and fetching too much data, creating inefficiency.
- [Instructor] Now let's look at how we can use … this SecItemCopyMatching in our code … to fetch an item out of a keychain. … So back in Xcode, … I'm going to create a new function up here at the top. … So after the class declaration on line nine, … I'll create some empty lines … and a new function on line 11. … I'll make it static func retrievePassword. … And we only have to pass in the username. … So I'll pass in username as a string … and we're going to return a string optional … because we may not find a password. … And then the next thing I'm going to do is create my query … specifying how I want to find this. … It's very similar to how we added it, … so I'm actually going to copy lines 38 through 41, … the query from our original store login function, … and I'm going to paste that on line 12. … So now I've got this query, … but we're not passing in the password anymore. … So I'll delete this line where we pass in the password data. … I'm just going to pass in the username … and I'll delete the comma at the end of that line. …
Author
Released
1/23/2020- Creating keychain queries
- Storing generic passwords
- Retrieving data from the keychain
- Handling search results
- Updating and deleting keychain values
- Working with keychain access groups
Skill Level Advanced
Duration
Views
Related Courses
-
iOS Development: Security
with Károly Nyisztor2h 6m Intermediate -
Biometric Authentication for iOS in Swift
with Bear Cahill43m 54s Intermediate
-
Introduction
-
1. iOS Keychain Services
-
Secure enclave41s
-
Attribute keys and values1m 44s
-
2. Storing Keychain Values
-
Xcode project configuration1m 31s
-
iOS code overview4m 12s
-
Storing a generic password2m 54s
-
Review keychain database2m 6s
-
-
3. Retrieving Data from the Keychain
-
Keychain search concepts4m 36s
-
Keychain search query1m 32s
-
Searching in keychain1m 40s
-
Handling search results3m 24s
-
-
4. Updating and Deleting Keychain Values
-
Update keychain preparation2m 34s
-
-
5. Keychain Sharing
-
Keychain access groups1m 39s
-
Sharing keychain data4m 18s
-
App group data sharing1m 20s
-
Sharing data in app group2m 42s
-
-
6. Building the App Challenges
-
Conclusion
-
Next steps32s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Keychain search query