@@ -139,28 +139,26 @@ public struct CoreDataStack {
139139 }
140140 private static let manager = CoreDataManager ( configuration: configuration)
141141
142- public static let mainContext = CoreDataStack . manager. managedObjectContext
142+ public static let mainContext = manager. managedObjectContext
143143
144- public static func save( context: NSManagedObjectContext , rollback: Bool = true , completion: @escaping ( Bool ) -> Void = { _ in } ) {
145- context. performAndWait {
146- CoreDataStack . manager. save ( context: context, rollback: rollback, completion: completion)
147- }
144+ public static func save( context: NSManagedObjectContext , rollback: Bool = true , completion: @escaping ( Bool ) -> ( ) = { _ in } ) {
145+ context. sync { manager. save ( context: context, rollback: rollback, completion: completion) }
148146 }
149147
150- public static func saveMainContext( rollback: Bool = true , completion: @escaping ( Bool ) -> Void = { _ in } ) {
151- CoreDataStack . save ( context: CoreDataStack . mainContext, rollback: rollback, completion: completion)
148+ public static func saveMainContext( rollback: Bool = true , completion: @escaping ( Bool ) -> ( ) = { _ in } ) {
149+ save ( context: mainContext, rollback: rollback, completion: completion)
152150 }
153151
154152 public static func createTemporaryMainContext( ) -> NSManagedObjectContext {
155- return CoreDataStack . manager. createTemporaryMainContext ( )
153+ return manager. createTemporaryMainContext ( )
156154 }
157155
158156 public static func createTemporaryBackgroundContext( ) -> NSManagedObjectContext {
159- return CoreDataStack . manager. createTemporaryBackgroundContext ( )
157+ return manager. createTemporaryBackgroundContext ( )
160158 }
161159
162160 public static func clearDataStore( ) throws {
163- try CoreDataStack . manager. clearDataStore ( )
161+ try manager. clearDataStore ( )
164162 }
165163}
166164
@@ -215,15 +213,15 @@ extension CoreDataStack {
215213 }
216214 #endif
217215
218- private static let InfoDictionaryTargetDisplayNameKey = " CFBundleDisplayName "
219- private static let InfoDictionaryTargetNameKey = String ( kCFBundleNameKey)
220- private static let DefaultTargetName = " UNKNOWN_TARGET_NAME "
216+ private static let infoDictionaryTargetDisplayNameKey = " CFBundleDisplayName "
217+ private static let infoDictionaryTargetNameKey = String ( kCFBundleNameKey)
218+ private static let defaultTargetName = " UNKNOWN_TARGET_NAME "
221219
222220 private init ( bundle: Bundle , modelName: String ? , sqliteName: String ? , storePath: URL ? , appSupportFolderName: String ? , removeNamespaces: Bool ) {
223221 func targetName( from bundle: Bundle ) -> String {
224- guard let infoDict = bundle. infoDictionary else { return Configuration . DefaultTargetName }
225- let name = infoDict [ Configuration . InfoDictionaryTargetDisplayNameKey ] ?? infoDict [ Configuration . InfoDictionaryTargetNameKey ]
226- return ( name as? String ) ?? Configuration . DefaultTargetName
222+ guard let infoDict = bundle. infoDictionary else { return Configuration . defaultTargetName }
223+ let name = infoDict [ Configuration . infoDictionaryTargetDisplayNameKey ] ?? infoDict [ Configuration . infoDictionaryTargetNameKey ]
224+ return ( name as? String ) ?? Configuration . defaultTargetName
227225 }
228226
229227 self . bundle = bundle
0 commit comments