mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
move coredata model into models package
This commit is contained in:
parent
5ff6d6789b
commit
0264564a64
4 changed files with 15 additions and 11 deletions
|
|
@ -0,0 +1,12 @@
|
|||
import CoreData
|
||||
import Foundation
|
||||
|
||||
/// An `NSPersistentContainer` subclass that lives in the `Models` package so that
|
||||
/// the data model is looked for in the same package bundle (rather than the main bundle)
|
||||
public class PersistentContainer: NSPersistentContainer {
|
||||
public static func make() -> PersistentContainer {
|
||||
let modelURL = Bundle.module.url(forResource: "CoreDataModel", withExtension: "momd")!
|
||||
let model = NSManagedObjectModel(contentsOf: modelURL)!
|
||||
return PersistentContainer(name: "DataModel", managedObjectModel: model)
|
||||
}
|
||||
}
|
||||
|
|
@ -118,13 +118,13 @@ public struct FeedItem: Identifiable, Hashable {
|
|||
object.slug = slug
|
||||
object.isArchived = isArchived
|
||||
object.contentReader = contentReader
|
||||
|
||||
|
||||
for label in labels {
|
||||
if let managedLabel = label.toManagedObject(inContext: context) {
|
||||
object.labels.insert(managedLabel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return object
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@ import CoreData
|
|||
import Foundation
|
||||
import Models
|
||||
|
||||
/// An `NSPersistentContainer` subclass that lives in the `Services` package so that
|
||||
/// the data model is looked for in the same package bundle (rather than the main bundle)
|
||||
final class PersistentContainer: NSPersistentContainer {}
|
||||
|
||||
public final class DataService: ObservableObject {
|
||||
public static var registerIntercomUser: ((String) -> Void)?
|
||||
public static var showIntercomMessenger: (() -> Void)?
|
||||
|
|
@ -27,11 +23,7 @@ public final class DataService: ObservableObject {
|
|||
public init(appEnvironment: AppEnvironment, networker: Networker) {
|
||||
self.appEnvironment = appEnvironment
|
||||
self.networker = networker
|
||||
self.persistentContainer = {
|
||||
let modelURL = Bundle.module.url(forResource: "CoreDataModel", withExtension: "momd")!
|
||||
let model = NSManagedObjectModel(contentsOf: modelURL)!
|
||||
return PersistentContainer(name: "DataModel", managedObjectModel: model)
|
||||
}()
|
||||
self.persistentContainer = PersistentContainer.make()
|
||||
|
||||
persistentContainer.loadPersistentStores { _, error in
|
||||
if let error = error {
|
||||
|
|
|
|||
Loading…
Reference in a new issue