From 27f3678d34df68f62d5081914664eef7d734e442 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 3 Jun 2015 01:33:50 +0900 Subject: [PATCH] Created Architecture (markdown) --- Architecture.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Architecture.md diff --git a/Architecture.md b/Architecture.md new file mode 100644 index 0000000..0faa817 --- /dev/null +++ b/Architecture.md @@ -0,0 +1,28 @@ +For maximum safety and performance, CoreStore will enforce coding patterns and practices it was designed for. (Don't worry, it's not as scary as it sounds.) But it is advisable to understand the "magic" of CoreStore before you use it in your apps. + +If you are already familiar with the inner workings of CoreData, here is a mapping of `CoreStore` abstractions: + +| *Core Data* | *CoreStore* | +| --- | --- | +| `NSManagedObjectModel` / `NSPersistentStoreCoordinator`
(.xcdatamodeld file) | `DataStack` | +| `NSPersistentStore`
("Configuration"s in the .xcdatamodeld file) | `DataStack` configuration
(multiple sqlite / in-memory stores per stack) | +| `NSManagedObjectContext` | `BaseDataTransaction` subclasses
(`SynchronousDataTransaction`, `AsynchronousDataTransaction`, `DetachedDataTransaction`) | + +Popular libraries [RestKit](https://github.com/RestKit/RestKit) and [MagicalRecord](https://github.com/magicalpanda/MagicalRecord) set up their `NSManagedObjectContext`s this way: + +nested contexts + +Nesting context saves from child context to the root context ensures maximum data integrity between contexts without blocking the main queue. But as Florian Kugler's investigation found out, merging contexts is still by far faster than saving nested contexts. CoreStore's `DataStack` takes the best of both worlds by treating the main `NSManagedObjectContext` as a read-only context, and only allows changes to be made within *transactions* on the child context: + +nested contexts and merge hybrid + +This allows for a butter-smooth main thread, while still taking advantage of safe nested contexts. + + +## Contents +- [[Architecture]] +- [[Setting up]] +- [[Saving and processing transactions]] +- [[Fetching and querying]] +- [[Logging and error handling]] +- [[Observing changes and notifications]] \ No newline at end of file