bookmarksController.managedObjectContext = self.manageObjectContext
bookmarksController.entityName = Bookmark.entityName
- let sort = NSSortDescriptor(key: "order", ascending: true)
+ let sort = NSSortDescriptor(key: #keyPath(Bookmark.order), ascending: true)
bookmarksController.sortDescriptors = [sort]
let mainMenu = NSApplication.shared.mainMenu
$0.element.1.fleetNumber = $0.offset + 1
}
- bind(NSBindingName(#keyPath(fleet1TPValue)), to: fleet1, withKeyPath: "totalTPValue")
- bind(NSBindingName(#keyPath(fleet2TPValue)), to: fleet2, withKeyPath: "totalTPValue")
+ bind(NSBindingName(#keyPath(fleet1TPValue)), to: fleet1, withKeyPath: #keyPath(FleetViewController.totalTPValue))
+ bind(NSBindingName(#keyPath(fleet2TPValue)), to: fleet2, withKeyPath: #keyPath(FleetViewController.totalTPValue))
- bind(NSBindingName(#keyPath(fleet1Seiku)), to: fleet1, withKeyPath: "totalSeiku")
- bind(NSBindingName(#keyPath(fleet2Seiku)), to: fleet2, withKeyPath: "totalSeiku")
+ bind(NSBindingName(#keyPath(fleet1Seiku)), to: fleet1, withKeyPath: #keyPath(FleetViewController.totalSeiku))
+ bind(NSBindingName(#keyPath(fleet2Seiku)), to: fleet2, withKeyPath: #keyPath(FleetViewController.totalSeiku))
- bind(NSBindingName(#keyPath(fleet1CalculatedSeiku)), to: fleet1, withKeyPath: "totalCalclatedSeiku")
- bind(NSBindingName(#keyPath(fleet2CalculatedSeiku)), to: fleet2, withKeyPath: "totalCalclatedSeiku")
+ bind(NSBindingName(#keyPath(fleet1CalculatedSeiku)), to: fleet1, withKeyPath: #keyPath(FleetViewController.totalCalclatedSeiku))
+ bind(NSBindingName(#keyPath(fleet2CalculatedSeiku)), to: fleet2, withKeyPath: #keyPath(FleetViewController.totalCalclatedSeiku))
}
deinit {
guard let moc = self.managedObjectContext else { return nil }
- let req = NSFetchRequest<Ship>(entityName: "Ship")
+ let req = NSFetchRequest<Ship>(entityName: Ship.entityName)
req.predicate = NSPredicate(format: "id = %ld", identifier)
guard let ships = try? moc.fetch(req) else { return nil }
return
}
- let resouces = ["fuel", "bull", "steel", "bauxite"]
+ let resouces = [#keyPath(Material.fuel), #keyPath(Material.bull), #keyPath(Material.steel), #keyPath(Material.bauxite)]
zip(gm, resouces).forEach {
private static let maxFleetNumber: Int = 4
private let details: [ShipDetailViewController]
- private let shipKeys = ["ship_0", "ship_1", "ship_2", "ship_3", "ship_4", "ship_5"]
+ private let shipKeys = [#keyPath(Deck.ship_0), #keyPath(Deck.ship_1), #keyPath(Deck.ship_2), #keyPath(Deck.ship_3), #keyPath(Deck.ship_4), #keyPath(Deck.ship_5)]
private let type: FleetViewType
private let fleetController = NSObjectController()
- private let shipObserveKeys = ["seiku", "lv", "equippedItem"]
+ private let shipObserveKeys = [#keyPath(Ship.seiku), #keyPath(Ship.lv), #keyPath(Ship.equippedItem)]
init?(viewType: FleetViewType) {
sakutekiCalculator = Formula33(Int(factor))
}
- fleetController.bind(NSBindingName("content"), to:self, withKeyPath:#keyPath(fleet), options:nil)
+ fleetController.bind(NSBindingName(#keyPath(NSArrayController.content)), to:self, withKeyPath:#keyPath(fleet), options:nil)
fleetController.addObserver(self, forKeyPath:"selection.name", context:nil)
shipKeys.forEach {
if context == &shipsContext {
switch keyPath {
- case "equippedItem":
+ case #keyPath(Ship.equippedItem):
notifyChangeValue(forKey: #keyPath(totalSakuteki))
notifyChangeValue(forKey: #keyPath(totalDrums))
notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
notifyChangeValue(forKey: #keyPath(totalTPValue))
- case "seiku":
+ case #keyPath(Ship.seiku):
notifyChangeValue(forKey: #keyPath(totalSeiku))
notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
- case "lv":
+ case #keyPath(Ship.lv):
notifyChangeValue(forKey: #keyPath(totalLevel))
default: break
let configuration: MappingConfiguration<Material>
private let keys = [
- "fuel", "bull", "steel", "bauxite",
- "kousokukenzo", "kousokushuhuku", "kaihatusizai", "screw"
+ #keyPath(Material.fuel), #keyPath(Material.bull), #keyPath(Material.steel), #keyPath(Material.bauxite),
+ #keyPath(Material.kousokukenzo), #keyPath(Material.kousokushuhuku), #keyPath(Material.kaihatusizai), #keyPath(Material.screw)
]
required init(_ apiResponse: APIResponse) {
final class QuestListViewController: NSViewController {
@objc let managedObjectContext = ServerDataStore.default.context
- @objc let sortDesciptors = [NSSortDescriptor(key: "no", ascending: true)]
+ @objc let sortDesciptors = [NSSortDescriptor(key: #keyPath(Quest.no), ascending: true)]
override var nibName: NSNib.Name {
func sortedMasterShipsById() -> [MasterShip] {
- let sortDesc = NSSortDescriptor(key: "id", ascending: true)
+ let sortDesc = NSSortDescriptor(key: #keyPath(MasterShip.id), ascending: true)
guard let ships = try? objects(of: MasterShip.entity, sortDescriptors: [sortDesc]) else { return [] }
func sortedMasterSlotItemsById() -> [MasterSlotItem] {
- let sortDesc = NSSortDescriptor(key: "id", ascending: true)
+ let sortDesc = NSSortDescriptor(key: #keyPath(MasterSlotItem.id), ascending: true)
guard let masterSlotItems = try? objects(of: MasterSlotItem.entity, sortDescriptors: [sortDesc]) else { return [] }
func sortedMasterSTypesById() -> [MasterSType] {
- let sortDesc = NSSortDescriptor(key: "id", ascending: true)
+ let sortDesc = NSSortDescriptor(key: #keyPath(MasterSType.id), ascending: true)
guard let masterSTypes = try? objects(of: MasterSType.entity, sortDescriptors: [sortDesc]) else { return [] }
func sortedSlotItemsById() -> [SlotItem] {
- let sortDesc = NSSortDescriptor(key: "id", ascending: true)
+ let sortDesc = NSSortDescriptor(key: #keyPath(SlotItem.id), ascending: true)
guard let slotItems = try? objects(of: SlotItem.entity, sortDescriptors: [sortDesc]) else { return [] }
func quest(by no: Int) -> Quest? {
- let p = NSPredicate(format: "%K = %ld", "no", no)
+ let p = NSPredicate(format: "%K = %ld", #keyPath(Quest.no), no)
guard let quests = try? objects(of: Quest.entity, predicate: p) else { return nil }
func quests(in range: CountableClosedRange<Int>) -> [Quest] {
- let p = NSPredicate(format: "%K In %@", "no", range.map {$0})
+ let p = NSPredicate(format: "%K In %@", #keyPath(Quest.no), range.map {$0})
guard let quests = try? objects(of: Quest.entity, predicate: p) else { return [] }
func sortedQuestByNo() -> [Quest] {
- let sortDesc = NSSortDescriptor(key: "no", ascending: true)
+ let sortDesc = NSSortDescriptor(key: #keyPath(Quest.no), ascending: true)
guard let quests = try? objects(of: Quest.entity, sortDescriptors: [sortDesc]) else { return [] }
if context == &shipContext {
- notifyChangeValue(forKey: "planeString0")
- notifyChangeValue(forKey: "planeString0Color")
- notifyChangeValue(forKey: "planeString1")
- notifyChangeValue(forKey: "planeString1Color")
- notifyChangeValue(forKey: "planeString2")
- notifyChangeValue(forKey: "planeString2Color")
- notifyChangeValue(forKey: "planeString3")
- notifyChangeValue(forKey: "planeString3Color")
- notifyChangeValue(forKey: "planeString4")
- notifyChangeValue(forKey: "planeString4Color")
+ notifyChangeValue(forKey: #keyPath(planeString0))
+ notifyChangeValue(forKey: #keyPath(planeString0Color))
+ notifyChangeValue(forKey: #keyPath(planeString1))
+ notifyChangeValue(forKey: #keyPath(planeString1Color))
+ notifyChangeValue(forKey: #keyPath(planeString2))
+ notifyChangeValue(forKey: #keyPath(planeString2Color))
+ notifyChangeValue(forKey: #keyPath(planeString3))
+ notifyChangeValue(forKey: #keyPath(planeString3Color))
+ notifyChangeValue(forKey: #keyPath(planeString4))
+ notifyChangeValue(forKey: #keyPath(planeString4Color))
return
}
if context == &equippedItem0Context {
- notifyChangeValue(forKey: "planeString0")
- notifyChangeValue(forKey: "planeString0Color")
+ notifyChangeValue(forKey: #keyPath(planeString0))
+ notifyChangeValue(forKey: #keyPath(planeString0Color))
return
}
if context == &equippedItem1Context {
- notifyChangeValue(forKey: "planeString1")
- notifyChangeValue(forKey: "planeString1Color")
+ notifyChangeValue(forKey: #keyPath(planeString1))
+ notifyChangeValue(forKey: #keyPath(planeString1Color))
return
}
if context == &equippedItem2Context {
- notifyChangeValue(forKey: "planeString2")
- notifyChangeValue(forKey: "planeString2Color")
+ notifyChangeValue(forKey: #keyPath(planeString2))
+ notifyChangeValue(forKey: #keyPath(planeString2Color))
return
}
if context == &equippedItem3Context {
- notifyChangeValue(forKey: "planeString3")
- notifyChangeValue(forKey: "planeString3Color")
+ notifyChangeValue(forKey: #keyPath(planeString3))
+ notifyChangeValue(forKey: #keyPath(planeString3Color))
return
}
if context == &equippedItem4Context {
- notifyChangeValue(forKey: "planeString4")
- notifyChangeValue(forKey: "planeString4Color")
+ notifyChangeValue(forKey: #keyPath(planeString4))
+ notifyChangeValue(forKey: #keyPath(planeString4Color))
return
}
shipController.sortDescriptors = UserDefaults.standard[.shipviewSortDescriptors]
shipController.addObserver(self, forKeyPath: NSBindingName.sortDescriptors.rawValue, context: nil)
- shipController.addObserver(self, forKeyPath: "arrangedObjects", context: nil)
+ shipController.addObserver(self, forKeyPath: #keyPath(NSArrayController.arrangedObjects), context: nil)
let tableViews = [expTableView, powerTableView, power2TableView, power3TableView]
tableViews
return
}
- if keyPath == "arrangedObjects" {
+ if keyPath == #keyPath(NSArrayController.arrangedObjects) {
- notifyChangeValue(forKey: "standardDeviation")
+ notifyChangeValue(forKey: #keyPath(standardDeviation))
return
}
func sortedDamagesById() -> [Damage] {
- let sortDescriptor = NSSortDescriptor(key: "id", ascending: true)
+ let sortDescriptor = NSSortDescriptor(key: #keyPath(Damage.id), ascending: true)
guard let damages = try? objects(of: Damage.entity, sortDescriptors: [sortDescriptor]) else { return [] }