2 // BookmarkDataStore.swift
5 // Created by Hori,Masaki on 2017/01/06.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 extension CoreDataIntormation {
12 static let bookmark = CoreDataIntormation(
13 modelName: "Bookmark",
14 storeFileName: "Bookmark.storedata",
15 storeOptions: [NSMigratePersistentStoresAutomaticallyOption: true,
16 NSInferMappingModelAutomaticallyOption: true],
17 storeType: NSSQLiteStoreType,
21 extension CoreDataCore {
22 static let bookmark = CoreDataCore(.bookmark)
25 class BookmarkDataStore: CoreDataAccessor, CoreDataManager {
26 static var `default` = BookmarkDataStore(type: .reader)
27 class func oneTimeEditor() -> BookmarkDataStore {
28 return BookmarkDataStore(type: .editor)
31 required init(type: CoreDataManagerType) {
32 managedObjectContext =
33 type == .reader ? core.parentManagedObjectContext
34 : core.editorManagedObjectContext()
40 let core = CoreDataCore.bookmark
41 var managedObjectContext: NSManagedObjectContext
44 extension BookmarkDataStore {
45 func createBookmark() -> Bookmark? {
46 return insertNewObject(for: Bookmark.entity)