OSDN Git Service

コード整形
[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     
13     static let bookmark = CoreDataConfiguration("Bookmark")
14 }
15
16 final class BookmarkDataStore: CoreDataAccessor, CoreDataManager {
17     
18     static let core = CoreDataCore(.bookmark)
19     
20     static let `default` = BookmarkDataStore(type: .reader)
21     
22     class func oneTimeEditor() -> BookmarkDataStore {
23         
24         return BookmarkDataStore(type: .editor)
25     }
26     
27     required init(type: CoreDataManagerType) {
28         
29         context = BookmarkDataStore.context(for: type)
30     }
31     
32     deinit {
33         
34         save()
35     }
36     
37     let context: NSManagedObjectContext
38 }
39
40 extension BookmarkDataStore {
41     
42     func createBookmark() -> Bookmark? {
43         
44         return insertNewObject(for: Bookmark.entity)
45     }
46 }