Skip to content

Commit

Permalink
Added NSPersistentStoreDescription option to ContextInitializer, vers…
Browse files Browse the repository at this point in the history
…ion 1.0.2
  • Loading branch information
PisinO committed Sep 14, 2020
1 parent 94642d6 commit 3d68353
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Infrastructure.DL.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'Infrastructure.DL'
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = 'UnitOfWork and Repository pattern guidelines'

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 2 additions & 0 deletions Infrastructure.DL/Classes/Context/ContextInitializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
//

import Foundation
import CoreData

public protocol ContextInitializer {
var datamodelName: String { get }
var datamodelBundle: Bundle { get }
var descriptions: [NSPersistentStoreDescription]? { get }
var onFinishedLoading: ((Error?) -> ())? { get }
}
4 changes: 4 additions & 0 deletions Infrastructure.DL/Classes/Context/ContextProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ContextProvider {

let pc = PersistentContainer(name: self.datamodelName, managedObjectModel: model)

if let descriptions = self.initializer.descriptions, descriptions.count > 0 {
pc.persistentStoreDescriptions = descriptions
}

pc.loadPersistentStores() { (description, error) in
self.initializer.onFinishedLoading?(error)
}
Expand Down

0 comments on commit 3d68353

Please sign in to comment.