How to query constant for keychain access

Viewed 63

I am developing an app with xcode8 and Swift3.

I try to use KeyChain to store username password and other sensible data. I know there are KeyChain query constants like following:

let kSecClassValue = NSString(format: kSecClass)
let kSecAttrAccountValue = NSString(format: kSecAttrAccount)
let kSecValueDataValue = NSString(format: kSecValueData)
let kSecClassGenericPasswordValue = NSString(format: kSecClassGenericPassword)
let kSecAttrServiceValue = NSString(format: kSecAttrService)
let kSecMatchLimitValue = NSString(format: kSecMatchLimit)
let kSecReturnDataValue = NSString(format: kSecReturnData)
let kSecMatchLimitOneValue = NSString(format: kSecMatchLimitOne)

I read couple of tutorials about storing data using KeyChain, they all use different query constants, some use all of above constants, some use part of it. I want to know:

  1. When to use what query constants?
  2. What are the purpose of each constant?
0 Answers
Related