• R/O
  • HTTP
  • SSH
  • HTTPS

KCD: Commit

main code repository.


Commit MetaInfo

Revisione341ef2774c1d7a27d9eb60edab905f1adc510a3 (tree)
Time2018-08-12 18:12:11
Authormasakih <masakih@user...>
Commitermasakih

Log Message

Doutaku を 1.0 にアップデート

Doutaku1.0に合わせてソースコードを変更

Change Summary

Incremental Difference

--- a/Cartfile.resolved
+++ b/Cartfile.resolved
@@ -1,2 +1,2 @@
11 github "SwiftyJSON/SwiftyJSON" "4.1.0"
2-github "masakih/Doutaku" "0.6.0"
2+github "masakih/Doutaku" "1.0"
--- a/KCD/AirBaseMapper.swift
+++ b/KCD/AirBaseMapper.swift
@@ -12,7 +12,7 @@ import SwiftyJSON
1212 final class AirBaseMapper: JSONMapper {
1313
1414 let apiResponse: APIResponse
15- let configuration = MappingConfiguration(entity: AirBase.entity,
15+ let configuration = MappingConfiguration(entity: AirBase.self,
1616 dataKeys: ["api_data", "api_air_base"],
1717 primaryKeys: ["area_id", "rid"],
1818 editorStore: ServerDataStore.oneTimeEditor())
--- a/KCD/BasicMapper.swift
+++ b/KCD/BasicMapper.swift
@@ -16,7 +16,7 @@ final class BasicMapper: JSONMapper {
1616 required init(_ apiResponse: APIResponse) {
1717
1818 self.apiResponse = apiResponse
19- self.configuration = MappingConfiguration(entity: Basic.entity,
19+ self.configuration = MappingConfiguration(entity: Basic.self,
2020 dataKeys: BasicMapper.dataKeys(apiResponse),
2121 editorStore: ServerDataStore.oneTimeEditor())
2222 }
--- a/KCD/BookmarkDataStoreAccessor.swift
+++ b/KCD/BookmarkDataStoreAccessor.swift
@@ -10,6 +10,6 @@ extension BookmarkDataStore {
1010
1111 func createBookmark() -> Bookmark? {
1212
13- return insertNewObject(for: Bookmark.entity)
13+ return insertNewObject(for: Bookmark.self)
1414 }
1515 }
--- a/KCD/BookmarkListViewController.swift
+++ b/KCD/BookmarkListViewController.swift
@@ -207,7 +207,7 @@ extension BookmarkListViewController: NSTableViewDelegate, NSTableViewDataSource
207207
208208 return
209209 }
210- guard let bookmark = store.object(of: Bookmark.entity, forURIRepresentation: uri) else {
210+ guard let bookmark = store.object(of: Bookmark.self, forURIRepresentation: uri) else {
211211
212212 return
213213 }
--- a/KCD/DeckMapper.swift
+++ b/KCD/DeckMapper.swift
@@ -16,7 +16,7 @@ final class DeckMapper: JSONMapper {
1616 required init(_ apiResponse: APIResponse) {
1717
1818 self.apiResponse = apiResponse
19- self.configuration = MappingConfiguration(entity: Deck.entity,
19+ self.configuration = MappingConfiguration(entity: Deck.self,
2020 dataKeys: DeckMapper.dataKeys(apiResponse),
2121 editorStore: ServerDataStore.oneTimeEditor())
2222 }
--- a/KCD/Entities.swift
+++ b/KCD/Entities.swift
@@ -9,40 +9,40 @@
99 import Doutaku
1010
1111 // MARK: - KCD model
12-extension AirBase: EntityProvider {}
13-extension AirBasePlaneInfo: EntityProvider {}
14-extension Basic: EntityProvider {}
15-extension Deck: EntityProvider {}
16-extension KenzoDock: EntityProvider {}
17-extension MasterFurniture: EntityProvider {}
18-extension MasterMapArea: EntityProvider {}
19-extension MasterMapInfo: EntityProvider {}
20-extension MasterMission: EntityProvider {}
21-extension MasterShip: EntityProvider {}
22-extension MasterSlotItem: EntityProvider {}
23-extension MasterSType: EntityProvider {}
24-extension MasterSlotItemEquipType: EntityProvider {}
25-extension MasterUseItem: EntityProvider {}
26-extension Material: EntityProvider {}
27-extension NyukyoDock: EntityProvider {}
28-extension Ship: EntityProvider {}
29-extension SlotItem: EntityProvider {}
30-extension Quest: EntityProvider {}
12+extension AirBase: Entity {}
13+extension AirBasePlaneInfo: Entity {}
14+extension Basic: Entity {}
15+extension Deck: Entity {}
16+extension KenzoDock: Entity {}
17+extension MasterFurniture: Entity {}
18+extension MasterMapArea: Entity {}
19+extension MasterMapInfo: Entity {}
20+extension MasterMission: Entity {}
21+extension MasterShip: Entity {}
22+extension MasterSlotItem: Entity {}
23+extension MasterSType: Entity {}
24+extension MasterSlotItemEquipType: Entity {}
25+extension MasterUseItem: Entity {}
26+extension Material: Entity {}
27+extension NyukyoDock: Entity {}
28+extension Ship: Entity {}
29+extension SlotItem: Entity {}
30+extension Quest: Entity {}
3131
3232 // MARK: - LocalData model
33-extension DropShipHistory: EntityProvider {}
34-extension HiddenDropShipHistory: EntityProvider {}
35-extension KaihatuHistory: EntityProvider {}
36-extension KenzoHistory: EntityProvider {}
37-extension KenzoMark: EntityProvider {}
33+extension DropShipHistory: Entity {}
34+extension HiddenDropShipHistory: Entity {}
35+extension KaihatuHistory: Entity {}
36+extension KenzoHistory: Entity {}
37+extension KenzoMark: Entity {}
3838
3939 // MARK: - Temporay model
40-extension Battle: EntityProvider {}
41-extension Damage: EntityProvider {}
42-extension GuardEscaped: EntityProvider {}
40+extension Battle: Entity {}
41+extension Damage: Entity {}
42+extension GuardEscaped: Entity {}
4343
4444 // MARK: - Bookmark model
45-extension Bookmark: EntityProvider {}
45+extension Bookmark: Entity {}
4646
4747 // MARK: - ResourceHistory model
48-extension Resource: EntityProvider {}
48+extension Resource: Entity {}
--- a/KCD/HistoryTableViewController.swift
+++ b/KCD/HistoryTableViewController.swift
@@ -160,7 +160,7 @@ final class KaihatsuHistoryTableViewController: HistoryTableViewController {
160160 override var predicateFormat: String { return "name contains $value" }
161161 override func objects(of predicate: Predicate?, in store: LocalDataStore) throws -> [NSManagedObject] {
162162
163- return try store.objects(of: KaihatuHistory.entity, predicate: predicate)
163+ return try store.objects(of: KaihatuHistory.self, predicate: predicate)
164164 }
165165 }
166166
@@ -169,7 +169,7 @@ final class KenzoHistoryTableViewController: HistoryTableViewController {
169169 override var predicateFormat: String { return "name contains $value" }
170170 override func objects(of predicate: Predicate?, in store: LocalDataStore) throws -> [NSManagedObject] {
171171
172- return try store.objects(of: KenzoHistory.entity, predicate: predicate)
172+ return try store.objects(of: KenzoHistory.self, predicate: predicate)
173173 }
174174 }
175175
@@ -178,6 +178,6 @@ final class DropShipHistoryTableViewController: HistoryTableViewController {
178178 override var predicateFormat: String { return "shipName contains $value" }
179179 override func objects(of predicate: Predicate?, in store: LocalDataStore) throws -> [NSManagedObject] {
180180
181- return try store.objects(of: DropShipHistory.entity, predicate: predicate)
181+ return try store.objects(of: DropShipHistory.self, predicate: predicate)
182182 }
183183 }
--- a/KCD/JSONMapper.swift
+++ b/KCD/JSONMapper.swift
@@ -10,15 +10,15 @@ import Cocoa
1010 import SwiftyJSON
1111 import Doutaku
1212
13-struct MappingConfiguration<T: NSManagedObject> {
13+struct MappingConfiguration<T: Entity> {
1414
15- let entity: Entity<T>
15+ let entity: T.Type
1616 let dataKeys: [String]
1717 let primaryKeys: [String]
1818 let editorStore: CoreDataAccessor
1919 let ignoreKeys: [String]
2020
21- init(entity: Entity<T>,
21+ init(entity: T.Type,
2222 dataKeys: [String] = ["api_data"],
2323 primaryKeys: [String] = ["id"],
2424 editorStore: CoreDataAccessor,
@@ -34,7 +34,7 @@ struct MappingConfiguration<T: NSManagedObject> {
3434
3535 protocol JSONMapper {
3636
37- associatedtype ObjectType: NSManagedObject
37+ associatedtype ObjectType: Entity
3838
3939 init(_ apiResponse: APIResponse)
4040
@@ -167,7 +167,7 @@ extension JSONMapper {
167167 }
168168 }
169169
170- private func sortedObjects<T>(_ entity: Entity<T>) -> [T] {
170+ private func sortedObjects<ResultType: Entity>(_ entity: ResultType.Type) -> [ResultType] {
171171
172172 let store = configuration.editorStore
173173
@@ -178,7 +178,7 @@ extension JSONMapper {
178178 return []
179179 }
180180
181- return (objects as NSArray).sortedArray(using: sortDescriptors) as? [T] ?? []
181+ return (objects as NSArray).sortedArray(using: sortDescriptors) as? [ResultType] ?? []
182182 }
183183 private func commintInContext() {
184184
--- a/KCD/KCManagedObject.swift
+++ b/KCD/KCManagedObject.swift
@@ -8,6 +8,7 @@
88
99 import Foundation
1010 import CoreData
11+import Doutaku
1112
1213 enum KCManagedObjectError: Error {
1314
@@ -68,7 +69,7 @@ class KCManagedObject: NSManagedObject {
6869 return value(forKey: k)
6970 }
7071
71- print("Entity \(type(of: self).entityName) dose not have key \(key)")
72+ print("Entity \(String(describing: self)) dose not have key \(key)")
7273
7374 return nil
7475 }
@@ -90,6 +91,6 @@ class KCManagedObject: NSManagedObject {
9091 return
9192 }
9293
93- print("Entity \(type(of: self).entityName) dose not have key \(key)")
94+ print("Entity \(String(describing: self)) dose not have key \(key)")
9495 }
9596 }
--- a/KCD/KenzoDockMapper.swift
+++ b/KCD/KenzoDockMapper.swift
@@ -16,7 +16,7 @@ final class KenzoDockMapper: JSONMapper {
1616 required init(_ apiResponse: APIResponse) {
1717
1818 self.apiResponse = apiResponse
19- self.configuration = MappingConfiguration(entity: KenzoDock.entity,
19+ self.configuration = MappingConfiguration(entity: KenzoDock.self,
2020 dataKeys: KenzoDockMapper.dataKeys(apiResponse),
2121 editorStore: ServerDataStore.oneTimeEditor())
2222 }
--- a/KCD/LocalDataStoreAccessor.swift
+++ b/KCD/LocalDataStoreAccessor.swift
@@ -20,7 +20,7 @@ extension LocalDataStore {
2020 )
2121 .and(Predicate(\DropShipHistory.mapArea, in: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]))
2222
23- guard let dropHistories = try? objects(of: DropShipHistory.entity, predicate: predicate) else {
23+ guard let dropHistories = try? objects(of: DropShipHistory.self, predicate: predicate) else {
2424
2525 return []
2626 }
@@ -30,7 +30,7 @@ extension LocalDataStore {
3030
3131 func createDropShipHistory(from: HiddenDropShipHistory) -> DropShipHistory? {
3232
33- guard let new = insertNewObject(for: DropShipHistory.entity) else {
33+ guard let new = insertNewObject(for: DropShipHistory.self) else {
3434
3535 Logger.shared.log("Can not create DropShipHistory")
3636
@@ -51,7 +51,7 @@ extension LocalDataStore {
5151
5252 func kaihatuHistories() -> [KaihatuHistory] {
5353
54- guard let kaihatuHistories = try? objects(of: KaihatuHistory.entity) else {
54+ guard let kaihatuHistories = try? objects(of: KaihatuHistory.self) else {
5555
5656 return []
5757 }
@@ -68,7 +68,7 @@ extension LocalDataStore {
6868 .or(Predicate(isNil: \KaihatuHistory.mark))
6969 )
7070
71- guard let kaihatuHistories = try? objects(of: KaihatuHistory.entity, predicate: predicate) else {
71+ guard let kaihatuHistories = try? objects(of: KaihatuHistory.self, predicate: predicate) else {
7272
7373 return []
7474 }
@@ -78,14 +78,14 @@ extension LocalDataStore {
7878
7979 func createKaihatuHistory() -> KaihatuHistory? {
8080
81- return insertNewObject(for: KaihatuHistory.entity)
81+ return insertNewObject(for: KaihatuHistory.self)
8282 }
8383
8484 func kenzoMark(byDockId dockId: Int) -> KenzoMark? {
8585
8686 let predicate = Predicate(\KenzoMark.kDockId, equalTo: dockId)
8787
88- guard let kenzoMarks = try? objects(of: KenzoMark.entity, predicate: predicate) else {
88+ guard let kenzoMarks = try? objects(of: KenzoMark.self, predicate: predicate) else {
8989
9090 return nil
9191 }
@@ -103,7 +103,7 @@ extension LocalDataStore {
103103 .and(Predicate(\KenzoMark.kaihatusizai, equalTo: docInfo.kaihatusizai))
104104 .and(Predicate(\KenzoMark.created_ship_id, equalTo: docInfo.shipId))
105105
106- guard let kenzoMarks = try? objects(of: KenzoMark.entity, predicate: predicate) else {
106+ guard let kenzoMarks = try? objects(of: KenzoMark.self, predicate: predicate) else {
107107
108108 return nil
109109 }
@@ -113,7 +113,7 @@ extension LocalDataStore {
113113
114114 func createKenzoMark() -> KenzoMark? {
115115
116- return insertNewObject(for: KenzoMark.entity)
116+ return insertNewObject(for: KenzoMark.self)
117117 }
118118
119119 func unmarkedKenzoHistories(befor days: Int) -> [KenzoHistory] {
@@ -125,7 +125,7 @@ extension LocalDataStore {
125125 .or(Predicate(isNil: \KenzoHistory.mark))
126126 )
127127
128- guard let kenzoHistories = try? objects(of: KenzoHistory.entity, predicate: predicate) else {
128+ guard let kenzoHistories = try? objects(of: KenzoHistory.self, predicate: predicate) else {
129129
130130 return []
131131 }
@@ -135,12 +135,12 @@ extension LocalDataStore {
135135
136136 func createKenzoHistory() -> KenzoHistory? {
137137
138- return insertNewObject(for: KenzoHistory.entity)
138+ return insertNewObject(for: KenzoHistory.self)
139139 }
140140
141141 func hiddenDropShipHistories() -> [HiddenDropShipHistory] {
142142
143- guard let dropShipHistories = try? objects(of: HiddenDropShipHistory.entity) else {
143+ guard let dropShipHistories = try? objects(of: HiddenDropShipHistory.self) else {
144144
145145 return []
146146 }
@@ -150,6 +150,6 @@ extension LocalDataStore {
150150
151151 func createHiddenDropShipHistory() -> HiddenDropShipHistory? {
152152
153- return insertNewObject(for: HiddenDropShipHistory.entity)
153+ return insertNewObject(for: HiddenDropShipHistory.self)
154154 }
155155 }
--- a/KCD/MasterFurnitureMapper.swift
+++ b/KCD/MasterFurnitureMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterFurnitureMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterFurniture.entity,
14+ let configuration = MappingConfiguration(entity: MasterFurniture.self,
1515 dataKeys: ["api_data", "api_mst_furniture"],
1616 editorStore: ServerDataStore.oneTimeEditor(),
1717 ignoreKeys: ["api_season"])
--- a/KCD/MasterMapAreaMapper.swift
+++ b/KCD/MasterMapAreaMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterMapAreaMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterMapArea.entity,
14+ let configuration = MappingConfiguration(entity: MasterMapArea.self,
1515 dataKeys: ["api_data", "api_mst_maparea"],
1616 editorStore: ServerDataStore.oneTimeEditor())
1717
--- a/KCD/MasterMapInfoMapper.swift
+++ b/KCD/MasterMapInfoMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterMapInfoMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterMapInfo.entity,
14+ let configuration = MappingConfiguration(entity: MasterMapInfo.self,
1515 dataKeys: ["api_data", "api_mst_mapinfo"],
1616 editorStore: ServerDataStore.oneTimeEditor())
1717
--- a/KCD/MasterMissionMapper.swift
+++ b/KCD/MasterMissionMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterMissionMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterMission.entity,
14+ let configuration = MappingConfiguration(entity: MasterMission.self,
1515 dataKeys: ["api_data", "api_mst_mission"],
1616 editorStore: ServerDataStore.oneTimeEditor(),
1717 ignoreKeys: ["api_deck_num", "api_disp_no"])
--- a/KCD/MasterSTypeMapper.swift
+++ b/KCD/MasterSTypeMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterSTypeMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterSType.entity,
14+ let configuration = MappingConfiguration(entity: MasterSType.self,
1515 dataKeys: ["api_data", "api_mst_stype"],
1616 editorStore: ServerDataStore.oneTimeEditor(),
1717 ignoreKeys: ["api_equip_type"])
--- a/KCD/MasterShipMapper.swift
+++ b/KCD/MasterShipMapper.swift
@@ -12,7 +12,7 @@ import SwiftyJSON
1212 final class MasterShipMapper: JSONMapper {
1313
1414 let apiResponse: APIResponse
15- let configuration = MappingConfiguration(entity: MasterShip.entity,
15+ let configuration = MappingConfiguration(entity: MasterShip.self,
1616 dataKeys: ["api_data", "api_mst_ship"],
1717 editorStore: ServerDataStore.oneTimeEditor())
1818
--- a/KCD/MasterSlotItemEquipTypeMapper.swift
+++ b/KCD/MasterSlotItemEquipTypeMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterSlotItemEquipTypeMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterSlotItemEquipType.entity,
14+ let configuration = MappingConfiguration(entity: MasterSlotItemEquipType.self,
1515 dataKeys: ["api_data", "api_mst_slotitem_equiptype"],
1616 editorStore: ServerDataStore.oneTimeEditor())
1717
--- a/KCD/MasterSlotItemMapper.swift
+++ b/KCD/MasterSlotItemMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterSlotItemMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterSlotItem.entity,
14+ let configuration = MappingConfiguration(entity: MasterSlotItem.self,
1515 dataKeys: ["api_data", "api_mst_slotitem"],
1616 editorStore: ServerDataStore.oneTimeEditor(),
1717 ignoreKeys: ["api_version"])
--- a/KCD/MasterUseItemMapper.swift
+++ b/KCD/MasterUseItemMapper.swift
@@ -11,7 +11,7 @@ import Cocoa
1111 final class MasterUseItemMapper: JSONMapper {
1212
1313 let apiResponse: APIResponse
14- let configuration = MappingConfiguration(entity: MasterUseItem.entity,
14+ let configuration = MappingConfiguration(entity: MasterUseItem.self,
1515 dataKeys: ["api_data", "api_mst_useitem"],
1616 editorStore: ServerDataStore.oneTimeEditor())
1717
--- a/KCD/MaterialMapper.swift
+++ b/KCD/MaterialMapper.swift
@@ -22,7 +22,7 @@ final class MaterialMapper: JSONMapper {
2222 required init(_ apiResponse: APIResponse) {
2323
2424 self.apiResponse = apiResponse
25- self.configuration = MappingConfiguration(entity: Material.entity,
25+ self.configuration = MappingConfiguration(entity: Material.self,
2626 dataKeys: MaterialMapper.dataKeys(apiResponse),
2727 editorStore: ServerDataStore.oneTimeEditor())
2828 }
--- a/KCD/NyukyoDockMapper.swift
+++ b/KCD/NyukyoDockMapper.swift
@@ -16,7 +16,7 @@ final class NyukyoDockMapper: JSONMapper {
1616 required init(_ apiResponse: APIResponse) {
1717
1818 self.apiResponse = apiResponse
19- self.configuration = MappingConfiguration(entity: NyukyoDock.entity,
19+ self.configuration = MappingConfiguration(entity: NyukyoDock.self,
2020 dataKeys: NyukyoDockMapper.dataKeys(apiResponse),
2121 editorStore: ServerDataStore.oneTimeEditor())
2222 }
--- a/KCD/ResourceHistoryDataStoreAccessor.swift
+++ b/KCD/ResourceHistoryDataStoreAccessor.swift
@@ -15,7 +15,7 @@ extension ResourceHistoryDataStore {
1515 let predicate = Predicate(\Resource.minute, in: minites)
1616 .and(Predicate(\Resource.date, lessThan: older))
1717
18- guard let resources = try? objects(of: Resource.entity, predicate: predicate) else {
18+ guard let resources = try? objects(of: Resource.self, predicate: predicate) else {
1919
2020 return []
2121 }
@@ -25,6 +25,6 @@ extension ResourceHistoryDataStore {
2525
2626 func createResource() -> Resource? {
2727
28- return insertNewObject(for: Resource.entity)
28+ return insertNewObject(for: Resource.self)
2929 }
3030 }
--- a/KCD/ServerDataStoreAccessor.swift
+++ b/KCD/ServerDataStoreAccessor.swift
@@ -12,7 +12,7 @@ extension ServerDataStore {
1212
1313 func airBases() -> [AirBase] {
1414
15- guard let airbase = try? objects(of: AirBase.entity) else {
15+ guard let airbase = try? objects(of: AirBase.self) else {
1616
1717 return []
1818 }
@@ -25,7 +25,7 @@ extension ServerDataStore {
2525 let predicate = Predicate(\AirBase.area_id, equalTo: area)
2626 .and(Predicate(\AirBase.rid, equalTo: base))
2727
28- guard let airBases = try? objects(of: AirBase.entity, predicate: predicate) else {
28+ guard let airBases = try? objects(of: AirBase.self, predicate: predicate) else {
2929
3030 return nil
3131 }
@@ -35,12 +35,12 @@ extension ServerDataStore {
3535
3636 func createAirBasePlaneInfo() -> AirBasePlaneInfo? {
3737
38- return insertNewObject(for: AirBasePlaneInfo.entity)
38+ return insertNewObject(for: AirBasePlaneInfo.self)
3939 }
4040
4141 func basic() -> Basic? {
4242
43- guard let basics = try? objects(of: Basic.entity) else {
43+ guard let basics = try? objects(of: Basic.self) else {
4444
4545 return nil
4646 }
@@ -50,14 +50,14 @@ extension ServerDataStore {
5050
5151 func createBasic() -> Basic? {
5252
53- return insertNewObject(for: Basic.entity)
53+ return insertNewObject(for: Basic.self)
5454 }
5555
5656 func decksSortedById() -> [Deck] {
5757
5858 let sortDecs = SortDescriptors(keyPath: \Deck.id, ascending: true)
5959
60- guard let decks = try? objects(of: Deck.entity, sortDescriptors: sortDecs) else {
60+ guard let decks = try? objects(of: Deck.self, sortDescriptors: sortDecs) else {
6161
6262 return []
6363 }
@@ -69,7 +69,7 @@ extension ServerDataStore {
6969
7070 let predicate = Predicate(\Deck.id, equalTo: id)
7171
72- guard let decks = try? objects(of: Deck.entity, predicate: predicate) else {
72+ guard let decks = try? objects(of: Deck.self, predicate: predicate) else {
7373
7474 return nil
7575 }
@@ -81,7 +81,7 @@ extension ServerDataStore {
8181
8282 let predicate = Predicate(\KenzoDock.id, equalTo: dockId)
8383
84- guard let kenzoDocks = try? objects(of: KenzoDock.entity, predicate: predicate) else {
84+ guard let kenzoDocks = try? objects(of: KenzoDock.self, predicate: predicate) else {
8585
8686 return nil
8787 }
@@ -93,7 +93,7 @@ extension ServerDataStore {
9393
9494 let predicate = Predicate(\MasterMapArea.id, equalTo: id)
9595
96- guard let mapAreas = try? objects(of: MasterMapArea.entity, predicate: predicate) else {
96+ guard let mapAreas = try? objects(of: MasterMapArea.self, predicate: predicate) else {
9797
9898 return nil
9999 }
@@ -106,7 +106,7 @@ extension ServerDataStore {
106106 let predicate = Predicate(\MasterMapInfo.maparea_id, equalTo: area)
107107 .and(Predicate(\MasterMapInfo.no, equalTo: no))
108108
109- guard let mapInfos = try? objects(of: MasterMapInfo.entity, predicate: predicate) else {
109+ guard let mapInfos = try? objects(of: MasterMapInfo.self, predicate: predicate) else {
110110
111111 return nil
112112 }
@@ -118,7 +118,7 @@ extension ServerDataStore {
118118
119119 let predicate = Predicate(\MasterMission.id, equalTo: id)
120120
121- guard let missions = try? objects(of: MasterMission.entity, predicate: predicate) else {
121+ guard let missions = try? objects(of: MasterMission.self, predicate: predicate) else {
122122
123123 return nil
124124 }
@@ -128,7 +128,7 @@ extension ServerDataStore {
128128
129129 func masterShips() -> [MasterShip] {
130130
131- guard let ships = try? objects(of: MasterShip.entity) else {
131+ guard let ships = try? objects(of: MasterShip.self) else {
132132
133133 return []
134134 }
@@ -140,7 +140,7 @@ extension ServerDataStore {
140140
141141 let sortDescs = SortDescriptors(keyPath: \MasterShip.id, ascending: true)
142142
143- guard let ships = try? objects(of: MasterShip.entity, sortDescriptors: sortDescs) else {
143+ guard let ships = try? objects(of: MasterShip.self, sortDescriptors: sortDescs) else {
144144
145145 return []
146146 }
@@ -152,7 +152,7 @@ extension ServerDataStore {
152152
153153 let predicate = Predicate(\MasterShip.id, equalTo: id)
154154
155- guard let ships = try? objects(of: MasterShip.entity, predicate: predicate) else {
155+ guard let ships = try? objects(of: MasterShip.self, predicate: predicate) else {
156156
157157 return nil
158158 }
@@ -164,7 +164,7 @@ extension ServerDataStore {
164164
165165 let sortDescs = SortDescriptors(keyPath: \MasterSlotItem.id, ascending: true)
166166
167- guard let masterSlotItems = try? objects(of: MasterSlotItem.entity, sortDescriptors: sortDescs) else {
167+ guard let masterSlotItems = try? objects(of: MasterSlotItem.self, sortDescriptors: sortDescs) else {
168168
169169 return []
170170 }
@@ -174,7 +174,7 @@ extension ServerDataStore {
174174
175175 func masterSlotItems() -> [MasterSlotItem] {
176176
177- guard let masterSlotItems = try? objects(of: MasterSlotItem.entity) else {
177+ guard let masterSlotItems = try? objects(of: MasterSlotItem.self) else {
178178
179179 return []
180180 }
@@ -186,7 +186,7 @@ extension ServerDataStore {
186186
187187 let predicate = Predicate(\MasterSlotItem.id, equalTo: id)
188188
189- guard let masterSlotItems = try? objects(of: MasterSlotItem.entity, predicate: predicate) else {
189+ guard let masterSlotItems = try? objects(of: MasterSlotItem.self, predicate: predicate) else {
190190
191191 return nil
192192 }
@@ -198,7 +198,7 @@ extension ServerDataStore {
198198
199199 let predicate = Predicate(\MasterSlotItemEquipType.id, equalTo: id)
200200
201- guard let types = try? objects(of: MasterSlotItemEquipType.entity, predicate: predicate) else {
201+ guard let types = try? objects(of: MasterSlotItemEquipType.self, predicate: predicate) else {
202202
203203 return nil
204204 }
@@ -208,7 +208,7 @@ extension ServerDataStore {
208208
209209 func masterSTypes() -> [MasterSType] {
210210
211- guard let masterSTypes = try? objects(of: MasterSType.entity) else {
211+ guard let masterSTypes = try? objects(of: MasterSType.self) else {
212212
213213 return []
214214 }
@@ -220,7 +220,7 @@ extension ServerDataStore {
220220
221221 let sortDescs = SortDescriptors(keyPath: \MasterSType.id, ascending: true)
222222
223- guard let masterSTypes = try? objects(of: MasterSType.entity, sortDescriptors: sortDescs) else {
223+ guard let masterSTypes = try? objects(of: MasterSType.self, sortDescriptors: sortDescs) else {
224224
225225 return []
226226 }
@@ -230,7 +230,7 @@ extension ServerDataStore {
230230
231231 func material() -> Material? {
232232
233- guard let materials = try? objects(of: Material.entity) else {
233+ guard let materials = try? objects(of: Material.self) else {
234234
235235 return nil
236236 }
@@ -240,14 +240,14 @@ extension ServerDataStore {
240240
241241 func createMaterial() -> Material? {
242242
243- return insertNewObject(for: Material.entity)
243+ return insertNewObject(for: Material.self)
244244 }
245245
246246 func nyukyoDock(by id: Int) -> NyukyoDock? {
247247
248248 let predicate = Predicate(\NyukyoDock.id, equalTo: id)
249249
250- guard let ndocks = try? objects(of: NyukyoDock.entity, predicate: predicate) else {
250+ guard let ndocks = try? objects(of: NyukyoDock.self, predicate: predicate) else {
251251
252252 return nil
253253 }
@@ -259,7 +259,7 @@ extension ServerDataStore {
259259
260260 let predicate = Predicate(\Deck.id, equalTo: deckId)
261261
262- guard let decks = try? objects(of: Deck.entity, predicate: predicate) else {
262+ guard let decks = try? objects(of: Deck.self, predicate: predicate) else {
263263
264264 return []
265265 }
@@ -281,7 +281,7 @@ extension ServerDataStore {
281281
282282 let predicate = Predicate(\Ship.id, equalTo: shipId)
283283
284- guard let ships = try? objects(of: Ship.entity, predicate: predicate) else {
284+ guard let ships = try? objects(of: Ship.self, predicate: predicate) else {
285285
286286 return nil
287287 }
@@ -293,7 +293,7 @@ extension ServerDataStore {
293293
294294 let predicate = Predicate(\Ship.id, equalTo: shipId)
295295
296- guard let ships = try? objects(of: Ship.entity, predicate: predicate) else {
296+ guard let ships = try? objects(of: Ship.self, predicate: predicate) else {
297297
298298 return []
299299 }
@@ -305,7 +305,7 @@ extension ServerDataStore {
305305
306306 let predicate = Predicate(\Ship.id, in: shipIds).negate()
307307
308- guard let ships = try? objects(of: Ship.entity, predicate: predicate) else {
308+ guard let ships = try? objects(of: Ship.self, predicate: predicate) else {
309309
310310 return []
311311 }
@@ -317,7 +317,7 @@ extension ServerDataStore {
317317
318318 let predicate = Predicate(\Ship.fleet, notEqualTo: 0)
319319
320- guard let ships = try? objects(of: Ship.entity, predicate: predicate) else {
320+ guard let ships = try? objects(of: Ship.self, predicate: predicate) else {
321321
322322 return []
323323 }
@@ -327,7 +327,7 @@ extension ServerDataStore {
327327
328328 func createShip() -> Ship? {
329329
330- return insertNewObject(for: Ship.entity)
330+ return insertNewObject(for: Ship.self)
331331 }
332332
333333 func masterSlotItemID(by slotItemId: Int) -> Int {
@@ -339,7 +339,7 @@ extension ServerDataStore {
339339
340340 let predicate = Predicate(\SlotItem.id, equalTo: slotItemId)
341341
342- guard let slotItems = try? objects(of: SlotItem.entity, predicate: predicate) else {
342+ guard let slotItems = try? objects(of: SlotItem.self, predicate: predicate) else {
343343
344344 return 0
345345 }
@@ -355,7 +355,7 @@ extension ServerDataStore {
355355
356356 let predicate = Predicate(\SlotItem.id, equalTo: itemId)
357357
358- guard let slotItems = try? objects(of: SlotItem.entity, predicate: predicate) else {
358+ guard let slotItems = try? objects(of: SlotItem.self, predicate: predicate) else {
359359
360360 return nil
361361 }
@@ -367,7 +367,7 @@ extension ServerDataStore {
367367
368368 let sortDescs = SortDescriptors(keyPath: \SlotItem.id, ascending: true)
369369
370- guard let slotItems = try? objects(of: SlotItem.entity, sortDescriptors: sortDescs) else {
370+ guard let slotItems = try? objects(of: SlotItem.self, sortDescriptors: sortDescs) else {
371371
372372 return []
373373 }
@@ -377,7 +377,7 @@ extension ServerDataStore {
377377
378378 func slotItems() -> [SlotItem] {
379379
380- guard let slotItems = try? objects(of: SlotItem.entity) else {
380+ guard let slotItems = try? objects(of: SlotItem.self) else {
381381
382382 return []
383383 }
@@ -389,7 +389,7 @@ extension ServerDataStore {
389389
390390 let predicate = Predicate(\SlotItem.id, in: itemIds)
391391
392- guard let slotItems = try? objects(of: SlotItem.entity, predicate: predicate) else {
392+ guard let slotItems = try? objects(of: SlotItem.self, predicate: predicate) else {
393393
394394 return []
395395 }
@@ -401,7 +401,7 @@ extension ServerDataStore {
401401
402402 let predicate = Predicate(\SlotItem.id, in: itemIds).negate()
403403
404- guard let slotItems = try? objects(of: SlotItem.entity, predicate: predicate) else {
404+ guard let slotItems = try? objects(of: SlotItem.self, predicate: predicate) else {
405405
406406 return []
407407 }
@@ -411,12 +411,12 @@ extension ServerDataStore {
411411
412412 func createSlotItem() -> SlotItem? {
413413
414- return insertNewObject(for: SlotItem.entity)
414+ return insertNewObject(for: SlotItem.self)
415415 }
416416
417417 func quests() -> [Quest] {
418418
419- guard let quests = try? objects(of: Quest.entity) else {
419+ guard let quests = try? objects(of: Quest.self) else {
420420
421421 return []
422422 }
@@ -428,7 +428,7 @@ extension ServerDataStore {
428428
429429 let predicate = Predicate(\Quest.no, equalTo: no)
430430
431- guard let quests = try? objects(of: Quest.entity, predicate: predicate) else {
431+ guard let quests = try? objects(of: Quest.self, predicate: predicate) else {
432432
433433 return nil
434434 }
@@ -440,7 +440,7 @@ extension ServerDataStore {
440440
441441 let predicate = Predicate(\Quest.no, in: range.map { $0 })
442442
443- guard let quests = try? objects(of: Quest.entity, predicate: predicate) else {
443+ guard let quests = try? objects(of: Quest.self, predicate: predicate) else {
444444
445445 return []
446446 }
@@ -452,7 +452,7 @@ extension ServerDataStore {
452452
453453 let sortDescs = SortDescriptors(keyPath: \Quest.no, ascending: true)
454454
455- guard let quests = try? objects(of: Quest.entity, sortDescriptors: sortDescs) else {
455+ guard let quests = try? objects(of: Quest.self, sortDescriptors: sortDescs) else {
456456
457457 return []
458458 }
@@ -462,6 +462,6 @@ extension ServerDataStore {
462462
463463 func createQuest() -> Quest? {
464464
465- return insertNewObject(for: Quest.entity)
465+ return insertNewObject(for: Quest.self)
466466 }
467467 }
--- a/KCD/ShipMapper.swift
+++ b/KCD/ShipMapper.swift
@@ -26,7 +26,7 @@ final class ShipMapper: JSONMapper {
2626 required init(_ apiResponse: APIResponse) {
2727
2828 self.apiResponse = apiResponse
29- self.configuration = MappingConfiguration(entity: Ship.entity,
29+ self.configuration = MappingConfiguration(entity: Ship.self,
3030 dataKeys: ShipMapper.dataKeys(apiResponse),
3131 editorStore: ServerDataStore.oneTimeEditor(),
3232 ignoreKeys: ShipMapper.ignoreKeys)
@@ -36,7 +36,7 @@ final class ShipMapper: JSONMapper {
3636 init(forSlotDepriveUnset apiResponse: APIResponse) {
3737
3838 self.apiResponse = apiResponse
39- self.configuration = MappingConfiguration(entity: Ship.entity,
39+ self.configuration = MappingConfiguration(entity: Ship.self,
4040 dataKeys: ["api_data", "api_ship_data", "api_unset_ship"],
4141 editorStore: ServerDataStore.oneTimeEditor(),
4242 ignoreKeys: ShipMapper.ignoreKeys)
--- a/KCD/SlotItemMapper.swift
+++ b/KCD/SlotItemMapper.swift
@@ -17,7 +17,7 @@ final class SlotItemMapper: JSONMapper {
1717 required init(_ apiResponse: APIResponse) {
1818
1919 self.apiResponse = apiResponse
20- self.configuration = MappingConfiguration(entity: SlotItem.entity,
20+ self.configuration = MappingConfiguration(entity: SlotItem.self,
2121 dataKeys: SlotItemMapper.dataKeys(apiResponse),
2222 editorStore: ServerDataStore.oneTimeEditor())
2323 }
--- a/KCD/TSVSupport.swift
+++ b/KCD/TSVSupport.swift
@@ -161,13 +161,13 @@ final class TSVSupport {
161161 }
162162 }
163163
164- private func localData<T, Value>(_ entity: Entity<T>, sortBy: KeyPath<T, Value>) -> [T] {
164+ private func localData<ResultType: Entity, Value>(_ type: ResultType.Type, sortBy: KeyPath<ResultType, Value>) -> [ResultType] {
165165
166166 let sortDesc = SortDescriptors(keyPath: sortBy, ascending: true)
167167
168- guard let array = try? store.objects(of: entity, sortDescriptors: sortDesc) else {
168+ guard let array = try? store.objects(of: type, sortDescriptors: sortDesc) else {
169169
170- print("Can not get \(entity)")
170+ print("Can not get \(type)")
171171
172172 return []
173173 }
@@ -177,7 +177,7 @@ final class TSVSupport {
177177
178178 private func dataOfKaihatuHistory() -> Data? {
179179
180- return localData(KaihatuHistory.entity, sortBy: \KaihatuHistory.date)
180+ return localData(KaihatuHistory.self, sortBy: \KaihatuHistory.date)
181181 .map {
182182 LFSeparateLine.empty
183183 .append($0.date)
@@ -198,7 +198,7 @@ final class TSVSupport {
198198
199199 private func dataOfKenzoHistory() -> Data? {
200200
201- return localData(KenzoHistory.entity, sortBy: \KenzoHistory.date)
201+ return localData(KenzoHistory.self, sortBy: \KenzoHistory.date)
202202 .map {
203203 LFSeparateLine.empty
204204 .append($0.date)
@@ -220,7 +220,7 @@ final class TSVSupport {
220220
221221 private func dataOfKenzoMark() -> Data? {
222222
223- return localData(KenzoMark.entity, sortBy: \KenzoMark.kDockId)
223+ return localData(KenzoMark.self, sortBy: \KenzoMark.kDockId)
224224 .map {
225225 LFSeparateLine.empty
226226 .append($0.date)
@@ -242,7 +242,7 @@ final class TSVSupport {
242242
243243 private func dataOfDropShipHistory() -> Data? {
244244
245- return localData(DropShipHistory.entity, sortBy: \DropShipHistory.date)
245+ return localData(DropShipHistory.self, sortBy: \DropShipHistory.date)
246246 .map {
247247 LFSeparateLine.empty
248248 .append($0.date)
@@ -306,7 +306,7 @@ final class TSVSupport {
306306
307307 let predicate = Predicate(\KaihatuHistory.date, equalTo: date)
308308
309- guard let oo = try? store.objects(of: KaihatuHistory.entity, predicate: predicate) else {
309+ guard let oo = try? store.objects(of: KaihatuHistory.self, predicate: predicate) else {
310310
311311 return
312312 }
@@ -314,7 +314,7 @@ final class TSVSupport {
314314
315315 return
316316 }
317- guard let obj = store.insertNewObject(for: KaihatuHistory.entity) else {
317+ guard let obj = store.insertNewObject(for: KaihatuHistory.self) else {
318318
319319 return
320320 }
@@ -383,7 +383,7 @@ final class TSVSupport {
383383
384384 let predicate = Predicate(\KenzoHistory.date, equalTo: date)
385385
386- guard let oo = try? store.objects(of: KenzoHistory.entity, predicate: predicate) else {
386+ guard let oo = try? store.objects(of: KenzoHistory.self, predicate: predicate) else {
387387
388388 return
389389 }
@@ -391,7 +391,7 @@ final class TSVSupport {
391391
392392 return
393393 }
394- guard let obj = store.insertNewObject(for: KenzoHistory.entity) else {
394+ guard let obj = store.insertNewObject(for: KenzoHistory.self) else {
395395
396396 return
397397 }
@@ -465,7 +465,7 @@ final class TSVSupport {
465465
466466 let predicate = Predicate(\KenzoMark.date, equalTo: date)
467467
468- guard let oo = try? store.objects(of: KenzoMark.entity, predicate: predicate) else {
468+ guard let oo = try? store.objects(of: KenzoMark.self, predicate: predicate) else {
469469
470470 return
471471 }
@@ -473,7 +473,7 @@ final class TSVSupport {
473473
474474 return
475475 }
476- guard let obj = store.insertNewObject(for: KenzoMark.entity) else {
476+ guard let obj = store.insertNewObject(for: KenzoMark.self) else {
477477
478478 return
479479 }
@@ -523,7 +523,7 @@ final class TSVSupport {
523523
524524 let predicate = Predicate(\DropShipHistory.date, equalTo: date)
525525
526- guard let oo = try? store.objects(of: DropShipHistory.entity, predicate: predicate) else {
526+ guard let oo = try? store.objects(of: DropShipHistory.self, predicate: predicate) else {
527527
528528 return
529529 }
@@ -531,7 +531,7 @@ final class TSVSupport {
531531
532532 return
533533 }
534- guard let obj = store.insertNewObject(for: DropShipHistory.entity) else {
534+ guard let obj = store.insertNewObject(for: DropShipHistory.self) else {
535535
536536 return
537537 }
--- a/KCD/TemporaryDataStoreAccessor.swift
+++ b/KCD/TemporaryDataStoreAccessor.swift
@@ -17,7 +17,7 @@ extension TemporaryDataStore {
1717
1818 func battles() -> [Battle] {
1919
20- guard let battles = try? self.objects(of: Battle.entity) else {
20+ guard let battles = try? self.objects(of: Battle.self) else {
2121
2222 return []
2323 }
@@ -32,14 +32,14 @@ extension TemporaryDataStore {
3232
3333 func createBattle() -> Battle? {
3434
35- return insertNewObject(for: Battle.entity)
35+ return insertNewObject(for: Battle.self)
3636 }
3737
3838 func sortedDamagesById() -> [Damage] {
3939
4040 let sortDescriptors = SortDescriptors(keyPath: \Damage.id, ascending: true)
4141
42- guard let damages = try? objects(of: Damage.entity, sortDescriptors: sortDescriptors) else {
42+ guard let damages = try? objects(of: Damage.self, sortDescriptors: sortDescriptors) else {
4343
4444 return []
4545 }
@@ -49,7 +49,7 @@ extension TemporaryDataStore {
4949
5050 func damages() -> [Damage] {
5151
52- guard let damages = try? objects(of: Damage.entity) else {
52+ guard let damages = try? objects(of: Damage.self) else {
5353
5454 return []
5555 }
@@ -59,12 +59,12 @@ extension TemporaryDataStore {
5959
6060 func createDamage() -> Damage? {
6161
62- return insertNewObject(for: Damage.entity)
62+ return insertNewObject(for: Damage.self)
6363 }
6464
6565 func guardEscaped() -> [GuardEscaped] {
6666
67- guard let escapeds = try? objects(of: GuardEscaped.entity) else {
67+ guard let escapeds = try? objects(of: GuardEscaped.self) else {
6868
6969 return []
7070 }
@@ -77,7 +77,7 @@ extension TemporaryDataStore {
7777 let predicate = Predicate(\GuardEscaped.shipID, equalTo: shipId)
7878 .and(Predicate(true: \GuardEscaped.ensured))
7979
80- guard let escapes = try? objects(of: GuardEscaped.entity, predicate: predicate) else {
80+ guard let escapes = try? objects(of: GuardEscaped.self, predicate: predicate) else {
8181
8282 return nil
8383 }
@@ -89,7 +89,7 @@ extension TemporaryDataStore {
8989
9090 let predicate = Predicate(false: \GuardEscaped.ensured)
9191
92- guard let escapeds = try? objects(of: GuardEscaped.entity, predicate: predicate) else {
92+ guard let escapeds = try? objects(of: GuardEscaped.self, predicate: predicate) else {
9393
9494 return []
9595 }
@@ -99,6 +99,6 @@ extension TemporaryDataStore {
9999
100100 func createGuardEscaped() -> GuardEscaped? {
101101
102- return insertNewObject(for: GuardEscaped.entity)
102+ return insertNewObject(for: GuardEscaped.self)
103103 }
104104 }
Show on old repository browser