UserDefaults & Keychain
UserDefaults, Keychain Services, secure storage, sensitive data, best practices
1What is UserDefaults in iOS?
What is UserDefaults in iOS?
답변
UserDefaults is a simple storage system for persisting non-sensitive data such as user preferences. Data is stored in plist format on disk and easily accessible. However, data is not encrypted, so sensitive information like passwords or authentication tokens should never be stored there.
2What is Keychain Services in iOS?
What is Keychain Services in iOS?
답변
Keychain Services is a security API that allows storing sensitive data in an encrypted and secure manner. It uses the Secure Enclave on modern devices to protect data. Keychain is the recommended approach for storing passwords, tokens, certificates, and other security-critical information for the application.
3How to access the standard instance of UserDefaults?
How to access the standard instance of UserDefaults?
답변
UserDefaults.standard is the standard method to access the default shared instance throughout the application. This instance automatically persists data to disk. Named instances can be created with init(suiteName:) to share data between an app and its extensions via App Groups, but UserDefaults.standard covers most simple use cases. Avoid creating multiple standard instances as it can cause data inconsistencies.
What types of data can UserDefaults store directly?
When is it appropriate to use UserDefaults instead of Keychain?
+17 면접 질문