OSDN Git Service

UAをVersion/10.0.3 Safari/602.4.8に変更
[kcd/KCD.git] / KCD / BookmarkDataStore.swift
1 //
2 //  BookmarkDataStore.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/06.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 extension CoreDataConfiguration {
12     static let bookmark = CoreDataConfiguration("Bookmark")
13 }
14 extension CoreDataCore {
15     static let bookmark = CoreDataCore(.bookmark)
16 }
17
18 class BookmarkDataStore: CoreDataAccessor, CoreDataManager {
19     static var `default` = BookmarkDataStore(type: .reader)
20     class func oneTimeEditor() -> BookmarkDataStore {
21         return BookmarkDataStore(type: .editor)
22     }
23     
24     required init(type: CoreDataManagerType) {
25         context = (type == .reader ? core.parentContext : core.editorContext())
26     }
27     deinit {
28         save()
29     }
30     
31     let core = CoreDataCore.bookmark
32     let context: NSManagedObjectContext
33 }
34
35 extension BookmarkDataStore {
36     func createBookmark() -> Bookmark? {
37         return insertNewObject(for: Bookmark.entity)
38     }
39 }