Instead of wrapping CoreData, use it directly :-)
ManagedToDos is a small example application demonstrating the use of
ManagedModels,
which adds some SwiftData-like @Model
support to regular CoreData.
Blog article describing ManagedModels: @Model
for CoreData.
The example uses two CoreData model classes, ToDo
:
@Model class ToDo: NSManagedObject {
var title : String
var isDone : Bool
var priority : Int
var created : Date
var due : Date?
var list : ToDoList
var isOverDue : Bool { ... }
}
and ToDoList
:
@Model class ToDoList: NSManagedObject {
var title : String
var toDos : Set<ToDo>
var hasOverdueItems : Bool { ... }
}
The macro implementation requires Xcode 15/Swift 5.9 for compilation.
The generated code itself though should backport way back to
iOS 10 / macOS 10.12 though (when NSPersistentContainer
was introduced).
Package URLs:
https://github.com/Data-swift/ManagedModels.git
https://github.com/Data-swift/ManagedToDosApp.git
ManagedModels has no other dependencies.
- ManagedModels
- Blog article:
@Model
for CoreData.
- Blog article:
- Apple:
- Lighter.swift, typesafe and superfast SQLite Swift tooling.
- ZeeQL, prototype of an EOF for Swift, with many database backends.
SwiftData and SwiftUI are trademarks owned by Apple Inc. Software maintained as a part of the this project is not affiliated with Apple Inc.
ManagedModels are brought to you by Helge Heß / ZeeZide. We like feedback, GitHub stars, cool contract work, presumably any form of praise you can think of.