iOS

UserDefaults & Keychain

UserDefaults, Keychain Services, secure storage, sensitive data, best practices

20 câu hỏi phỏng vấn·
Junior
1

What is UserDefaults in iOS?

Câu trả lời

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.

2

What is Keychain Services in iOS?

Câu trả lời

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.

3

How to access the standard instance of UserDefaults?

Câu trả lời

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.

4

What types of data can UserDefaults store directly?

5

When is it appropriate to use UserDefaults instead of Keychain?

+17 câu hỏi phỏng vấn

Nắm vững iOS cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí