Browse Questions
  • Themis is an open-source, cross-platform cryptographic library that packages a few high-level, hard-to-misuse primitives instead of exposing raw ciphers.
  • - Instruments — CPU Profiler, Time Profiler, Allocations, Leaks, Core Data - Xcode Memory Graph — find retain cycles and leaked objects - View Hierarchy Debugger — spot off-screen renders,…
  • Swift's async/await is directly supported in XCTest — mark your test function as async throws and await the result.
  • @AppStorage is a property wrapper that reads and writes to UserDefaults and automatically refreshes the view when the value changes.

Answer: @AppStorage is a property wrapper that reads and writes to UserDefaults and automatically refreshes the view when the value changes. Use it for lightweight user preferences.

Code Example:

struct SettingsView: View {
    @AppStorage("isDarkMode") private var isDarkMode = false
    @AppStorage("fontSize") private var fontSize = 16.0
    @AppStorage("username") private var username = ""

    var body: some View {
        Form {
            Toggle("Dark Mode", isOn: $isDarkMode)
            Slider(value: $fontSize, in: 12...24)
            TextField("Username", text: $username)
        }
    }
}

When to use vs not:

  • ✅ Simple user preferences (theme, font size, onboarding seen)
  • ❌ Large data, sensitive data, or complex objects — use Core Data, Keychain, or a file instead