인터페이스는 현지화되어 있으며, Skill 소개와 설명 문서는 선택한 언어로 AI가 자동 번역합니다. 코드·명령어·경로·전문 용어는 원문을 유지하며 원작자 문서가 우선합니다.
Skills 둘러보기
데이터 및 연구 · SKILL.md

ios-persistence

ios-persistence

Implement local persistence with SwiftData, Core Data, and secure storage. Use when setting up SwiftData models, Core Data stacks, or local persistence in iOS.

Independent GitHub snapshot · Automated classification · Original documentation governs

Skill 문서

GitHub

name: ios-persistence description: Implement local persistence with SwiftData, Core Data, and secure storage. Use when setting up SwiftData models, Core Data stacks, or local persistence in iOS. metadata: triggers: files: - '/*.xcdatamodeld' - '/*Model.swift' keywords: - PersistentContainer - FetchRequest - ManagedObject - Query - ModelContainer - Repository

iOS Persistence

Priority: P0 (CRITICAL)

Implementation Workflow

  1. Choose storage tier — SwiftData for iOS 17+, Core Data for legacy, Apple secure credential storage for secrets, UserDefaults for flags only.
  2. Define models — Use @Model macro (SwiftData) or .xcdatamodeld (Core Data).
  3. Configure container — Use @MainActor for ModelContainer (SwiftData) or NSPersistentContainer (Core Data).
  4. Perform background writes — Use newBackgroundContext() (Core Data) to avoid UI lag; never heavy I/O on viewContext.
  5. Secure sensitive data — Use secure storage for tokens and PII; never store in UserDefaults.

See SwiftData and Core Data implementation examples

Anti-Patterns

  • No Heavy I/O on viewContext: Use private background contexts
  • No String-based Predicates: Use KeyPaths or generated helpers
  • No Missing Merge Strategy: Set the merge policy (mergePolicy) explicitly (e.g., mergeByPropertyObjectTrump)

References

저장한 Skills