Skip to content
Back to skills

Ios Persistence

ASecurity

Use the container that matches your persistence tier: - SwiftData on iOS 17+: configure a `ModelContainer` and keep it on the main actor. - Core Data for older apps: configure an `NSPersistentContainer`. SwiftData example: ```swift import SwiftData @Model final class Note { var title: String init(title: String) { self.title = title } } @MainActor final class PersistenceController { let container: ModelContainer init(inMemory: Bool = false) throws { let config = ModelConfiguration(isStoredInMe...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentgoswift

Security analysis

A100/100

Pro scans all 11 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill ios-persistence --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ios Persistence?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ios Persistence
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-ios-persistence-098ecc22/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-ios-persistence-098ecc22)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
Use the container that matches your persistence tier:

- SwiftData on iOS 17+: configure a `ModelContainer` and keep it on the main actor.
- Core Data for older apps: configure an `NSPersistentContainer`.

SwiftData example:

```swift
import SwiftData

@Model
final class Note {
    var title: String

    init(title: String) {
        self.title = title
    }
}

@MainActor
final class PersistenceController {
    let container: ModelContainer

    init(inMemory: Bool = false) throws {
        let config = ModelConfiguration(isStoredInMemoryOnly: inMemory)
        container = try ModelContainer(for: Note.self, configurations: config)
    }
}
```

Core Data example:

```swift
import CoreData

final class PersistenceController {
    static let shared = PersistenceController()

    let container: NSPersistentContainer

    init(inMemory: Bool = false) {
        container = NSPersistentContainer(name: "MyModel")

        if inMemory {
            container.persistentStoreDescriptions.first?.url = URL(fileURLWithPath: "/dev/null")
        }

        container.loadPersistentStores { _, error in
            if let error = error {
                fatalError("Failed to load store: \(error)")
            }
        }

        container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
        container.viewContext.automaticallyMergesChangesFromParent = true
    }
}
```

Good defaults:

- Use SwiftData for new iOS 17+ apps.
- Keep SwiftData container setup on `@MainActor`.
- For Core Data, set an explicit merge policy.
- Do heavy writes in a background context with `newBackgroundContext()`, not on `viewContext`.
- Store secrets like tokens in secure storage, not `UserDefaults`.

Files in this skill

  • eval-1.baseline.md707 B
  • eval-1.with-skill.md2.6 KB
  • eval-2.baseline.md849 B
  • eval-2.with-skill.md1.7 KB
  • eval-3.baseline.md853 B
  • eval-3.with-skill.md486 B
  • trigger-1.md158 B
  • trigger-2.md170 B
  • trigger-3.md161 B
  • trigger-4.md118 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.