From 8c30ec3a3d01159f7869700374d03c6a86bcdfec Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 9 Jan 2019 11:59:06 +0900 Subject: [PATCH] minor fixes on Playgrounds and Demo app --- .../CustomLoggerViewController.swift | 17 ++++++++++------- Playground.playground/Contents.swift | 3 --- Playground.playground/timeline.xctimeline | 6 ------ 3 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 Playground.playground/timeline.xctimeline diff --git a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift index 1548c5a..c92bbaf 100644 --- a/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift +++ b/CoreStoreDemo/CoreStoreDemo/Loggers Demo/CustomLoggerViewController.swift @@ -16,11 +16,6 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { // MARK: NSObject - deinit { - - CoreStore.logger = DefaultLogger() - } - let dataStack = DataStack() // MARK: UIViewController @@ -30,13 +25,14 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { super.viewDidLoad() try! self.dataStack.addStorageAndWait(SQLiteStore(fileName: "emptyStore.sqlite")) - CoreStore.logger = self } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - + + CoreStore.logger = self + let alert = UIAlertController( title: "Logger Demo", message: "This demo shows how to plug-in any logging framework to CoreStore.\n\nThe view controller implements CoreStoreLogger and appends all logs to the text view.", @@ -46,6 +42,13 @@ class CustomLoggerViewController: UIViewController, CoreStoreLogger { self.present(alert, animated: true, completion: nil) } + override func viewDidDisappear(_ animated: Bool) { + + super.viewDidDisappear(animated) + + CoreStore.logger = DefaultLogger() + } + // MARK: CoreStoreLogger diff --git a/Playground.playground/Contents.swift b/Playground.playground/Contents.swift index ccc21c8..e2147f9 100644 --- a/Playground.playground/Contents.swift +++ b/Playground.playground/Contents.swift @@ -14,7 +14,6 @@ class Person: CoreStoreObject { } /// ======================= - /// Stack setup =========== let dataStack = DataStack( CoreStoreSchema( @@ -28,7 +27,6 @@ let dataStack = DataStack( try dataStack.addStorageAndWait(SQLiteStore(fileName: "data.sqlite")) /// ======================= - /// Transactions ========== dataStack.perform(synchronous: { transaction in @@ -42,7 +40,6 @@ dataStack.perform(synchronous: { transaction in }) /// ======================= - /// Accessing Objects ===== let bird = dataStack.fetchOne(From().where(\.species == "Sparrow"))! bird.species.value diff --git a/Playground.playground/timeline.xctimeline b/Playground.playground/timeline.xctimeline deleted file mode 100644 index bf468af..0000000 --- a/Playground.playground/timeline.xctimeline +++ /dev/null @@ -1,6 +0,0 @@ - - - - -