Swift/UIKit
KeyChain의 SecItemAdd(_:_:) 에러 조회하기
devKen
2023. 2. 10. 15:04
Apple은 왜 개발자 UX는 생각 안 하지? Apple Document 왜 이렇게 하는지 잘 이해가 안 갈 때가 많다.
아래와 같이 조건문으로 처리하면 원하는 에러 코드를 번역해서 문자로 조회가 가능하다.
let status = SecItemAdd(query as CFDictionary, nil)
if status == errSecSuccess {
print("Successfully added to keychain.")
} else {
if let error: String = SecCopyErrorMessageString(status, nil) as String? {
print(error)
}
}
ref
https://stackoverflow.com/questions/34051482/secitemadd-keep-return-50-error-in-swift