|
|
|
@ -17,12 +17,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { |
|
|
|
|
|
|
|
|
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { |
|
|
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { |
|
|
|
|
|
|
|
|
|
|
|
if let content = PreferencesStorage.main.getContent(filename: "main.txt") { |
|
|
|
// if let content = PreferencesStorage.main.getContent(filename: "main.txt") { |
|
|
|
let note = Note(context: AppDelegate.viewContext) |
|
|
|
// let note = Note(context: AppDelegate.viewContext) |
|
|
|
note.content = content |
|
|
|
// note.content = content |
|
|
|
AppDelegate.shared.saveContext() |
|
|
|
// AppDelegate.shared.saveContext() |
|
|
|
print("default note created") |
|
|
|
// print("default note created") |
|
|
|
} |
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// Override point for customization after application launch. |
|
|
|
// Override point for customization after application launch. |
|
|
|
return true |
|
|
|
return true |
|
|
|
@ -53,6 +53,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
let container = NSPersistentCloudKitContainer(name: "Notes") |
|
|
|
let container = NSPersistentCloudKitContainer(name: "Notes") |
|
|
|
container.loadPersistentStores(completionHandler: { (storeDescription, error) in |
|
|
|
container.loadPersistentStores(completionHandler: { (storeDescription, error) in |
|
|
|
|
|
|
|
|
|
|
|
if let error = error as NSError? { |
|
|
|
if let error = error as NSError? { |
|
|
|
// Replace this implementation with code to handle the error appropriately. |
|
|
|
// Replace this implementation with code to handle the error appropriately. |
|
|
|
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. |
|
|
|
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. |
|
|
|
@ -68,6 +69,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate { |
|
|
|
fatalError("Unresolved error \(error), \(error.userInfo)") |
|
|
|
fatalError("Unresolved error \(error), \(error.userInfo)") |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// container.viewContext.mergePolicy = NSMergeByPropertyStoreTrumpMergePolicy |
|
|
|
|
|
|
|
// container.viewContext.automaticallyMergesChangesFromParent = true |
|
|
|
|
|
|
|
|
|
|
|
return container |
|
|
|
return container |
|
|
|
}() |
|
|
|
}() |
|
|
|
|
|
|
|
|
|
|
|
|