rId = 1
- airBaseController.addObserver(self, forKeyPath: "content", context: nil)
+ airBaseController.addObserver(self, forKeyPath: #keyPath(airBaseController.content), context: nil)
updateAreaRadio()
updatePlaneSegment()
of object: Any?,
change: [NSKeyValueChangeKey: Any]?,
context: UnsafeMutableRawPointer?) {
- guard keyPath == "content" else {
+ guard keyPath == #keyPath(airBaseController.content) else {
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
return
}
didSet {
guard let representedObject = representedObject else { return }
[
- (NSContentArrayBinding, "screenshots"),
- (NSSortDescriptorsBinding, "sortDescriptors"),
- (NSSelectionIndexesBinding, "selectedIndexes"),
- (NSFilterPredicateBinding, "filterPredicate")
+ (NSContentArrayBinding, #keyPath(ScreenshotModel.screenshots)),
+ (NSSortDescriptorsBinding, #keyPath(ScreenshotModel.sortDescriptors)),
+ (NSSelectionIndexesBinding, #keyPath(ScreenshotModel.selectedIndexes)),
+ (NSFilterPredicateBinding, #keyPath(ScreenshotModel.filterPredicate))
]
.forEach {
arrayController.bind($0.0, to: representedObject, withKeyPath: $0.1, options: nil)
}
class func keyPathsForValuesAffectingFlagShipName() -> Set<String> {
- return ["flagShipID"]
+ return [#keyPath(flagShipID)]
}
let managedObjectContext = ServerDataStore.default.context
fleetViewController.shipOrder = UserDefaults.standard.fleetViewShipOrder
fleetViewController.enableAnimation = true
- bind("flagShipID", to: deckContoller, withKeyPath: "selection.ship_0", options: nil)
+ bind(#keyPath(flagShipID), to: deckContoller, withKeyPath: "selection.ship_0", options: nil)
NotificationCenter.default
.addObserver(forName: .CombinedDidCange, object: nil, queue: nil) {
shipTypeSegment.bind(NSSelectedIndexBinding,
to: tabViewItemViewControllers[0],
- withKeyPath: "selectedShipType",
+ withKeyPath: #keyPath(MainTabVIewItemViewController.selectedShipType),
options: nil)
let o = selectedMainTabIndex
selectedMainTabIndex = o
button.isHidden = !vc.hasShipTypeSelector
self.shipTypeSegment.bind(NSSelectedIndexBinding,
to: vc,
- withKeyPath: "selectedShipType",
+ withKeyPath: #keyPath(MainTabVIewItemViewController.selectedShipType),
options: nil)
}
return mainTouchBar
required init?(coder: NSCoder) {
super.init(coder: coder)
- self.addObserver(self, forKeyPath: "selectionIndexPaths", context: nil)
+ self.addObserver(self, forKeyPath: #keyPath(selectionIndexPaths), context: nil)
}
deinit {
- self.removeObserver(self, forKeyPath: "selectionIndexPaths")
+ self.removeObserver(self, forKeyPath: #keyPath(selectionIndexPaths))
}
override func observeValue(forKeyPath keyPath: String?,
class DocksViewController: MainTabVIewItemViewController {
deinit {
- ["deck2Time", "mission2Name",
- "deck3Time", "mission3Name",
- "deck4Time", "mission4Name"]
+ [#keyPath(deck2Time), #keyPath(mission2Name),
+ #keyPath(deck3Time), #keyPath(mission3Name),
+ #keyPath(deck4Time), #keyPath(mission4Name)]
.forEach { unbind($0) }
- ["nDock1Time", "nDock1ShipName",
- "nDock2Time", "nDock2ShipName",
- "nDock3Time", "nDock3ShipName",
- "nDock4Time", "nDock4ShipName"]
+ [#keyPath(nDock1Time), #keyPath(nDock1ShipName),
+ #keyPath(nDock2Time), #keyPath(nDock2ShipName),
+ #keyPath(nDock3Time), #keyPath(nDock3ShipName),
+ #keyPath(nDock4Time), #keyPath(nDock4ShipName)]
.forEach { unbind($0) }
- ["kDock1Time", "kDock2Time", "kDock3Time", "kDock4Time"]
+ [#keyPath(kDock1Time), #keyPath(kDock2Time), #keyPath(kDock3Time), #keyPath(kDock4Time)]
.forEach { unbind($0) }
["selection", "selection.no", "content.battleCell"]
change: [NSKeyValueChangeKey: Any]?,
context: UnsafeMutableRawPointer?) {
if keyPath == "selection" || keyPath == "content.battleCell" {
- notifyChangeValue(forKey: "sortieString")
+ notifyChangeValue(forKey: #keyPath(sortieString))
return
}
if keyPath == "selection.no" {
- notifyChangeValue(forKey: "cellNumber")
+ notifyChangeValue(forKey: #keyPath(cellNumber))
return
}
private func setupStatus() {
let missionKeys = [
- ("deck2Time", "mission2Name"),
- ("deck3Time", "mission3Name"),
- ("deck4Time", "mission4Name")
+ (#keyPath(deck2Time), #keyPath(mission2Name)),
+ (#keyPath(deck3Time), #keyPath(mission3Name)),
+ (#keyPath(deck4Time), #keyPath(mission4Name))
]
zip(missionStates, missionKeys).forEach {
- bind($0.1.0, to: $0.0, withKeyPath: "time", options: nil)
- bind($0.1.1, to: $0.0, withKeyPath: "name", options: nil)
+ bind($0.1.0, to: $0.0, withKeyPath: #keyPath(MissionStatus.time), options: nil)
+ bind($0.1.1, to: $0.0, withKeyPath: #keyPath(MissionStatus.name), options: nil)
}
let ndockKeys = [
- ("nDock1Time", "nDock1ShipName"),
- ("nDock2Time", "nDock2ShipName"),
- ("nDock3Time", "nDock3ShipName"),
- ("nDock4Time", "nDock4ShipName")
+ (#keyPath(nDock1Time), #keyPath(nDock1ShipName)),
+ (#keyPath(nDock2Time), #keyPath(nDock2ShipName)),
+ (#keyPath(nDock3Time), #keyPath(nDock3ShipName)),
+ (#keyPath(nDock4Time), #keyPath(nDock4ShipName))
]
zip(ndockStatus, ndockKeys).forEach {
- bind($0.1.0, to: $0.0, withKeyPath: "time", options: nil)
- bind($0.1.1, to: $0.0, withKeyPath: "name", options: nil)
+ bind($0.1.0, to: $0.0, withKeyPath: #keyPath(MissionStatus.time), options: nil)
+ bind($0.1.1, to: $0.0, withKeyPath: #keyPath(MissionStatus.name), options: nil)
}
- let kdockKeys = ["kDock1Time", "kDock2Time", "kDock3Time", "kDock4Time"]
+ let kdockKeys = [#keyPath(kDock1Time), #keyPath(kDock2Time), #keyPath(kDock3Time), #keyPath(kDock4Time)]
zip(kdockStatus, kdockKeys).forEach {
- bind($0.1, to: $0.0, withKeyPath: "time", options: nil)
+ bind($0.1, to: $0.0, withKeyPath: #keyPath(MissionStatus.time), options: nil)
}
}
let managedObjectContext = BookmarkManager.shared().manageObjectContext
deinit {
- webView.removeObserver(self, forKeyPath: "canGoBack")
- webView.removeObserver(self, forKeyPath: "canGoForward")
+ webView.removeObserver(self, forKeyPath: #keyPath(webView.canGoBack))
+ webView.removeObserver(self, forKeyPath: #keyPath(webView.canGoForward))
}
@IBOutlet var webView: WebView!
override func windowDidLoad() {
super.windowDidLoad()
- webView.addObserver(self, forKeyPath: "canGoBack", context: nil)
- webView.addObserver(self, forKeyPath: "canGoForward", context: nil)
+ webView.addObserver(self, forKeyPath: #keyPath(webView.canGoBack), context: nil)
+ webView.addObserver(self, forKeyPath: #keyPath(webView.canGoForward), context: nil)
webView.applicationNameForUserAgent = AppDelegate.shared.appNameForUserAgent
webView.frameLoadDelegate = self
}
of object: Any?,
change: [NSKeyValueChangeKey: Any]?,
context: UnsafeMutableRawPointer?) {
- if keyPath == "canGoBack" {
+ if keyPath == #keyPath(webView.canGoBack) {
goSegment.setEnabled(webView.canGoBack, forSegment: 0)
return
}
- if keyPath == "canGoForward" {
+ if keyPath == #keyPath(webView.canGoForward) {
goSegment.setEnabled(webView.canGoForward, forSegment: 1)
return
}
override func viewDidLoad() {
super.viewDidLoad()
- fleetController.bind("content", to:self, withKeyPath:"fleet", options:nil)
+ fleetController.bind("content", to:self, withKeyPath:#keyPath(fleet), options:nil)
fleetController.addObserver(self, forKeyPath:"selection.name", context:nil)
shipKeys.forEach {
let keyPath = "selection.\($0)"
NotificationCenter.default
.addObserver(forName: .DidPrepareFleet, object: nil, queue: nil) { [weak self] _ in
guard let `self` = self else { return }
- self.notifyChangeValue(forKey: "fleetNumber")
+ self.notifyChangeValue(forKey: #keyPath(fleetNumber))
}
}
override func observeValue(forKeyPath keyPath: String?,
if context == &shipsContext {
switch keyPath {
case "sakuteki_0":
- notifyChangeValue(forKey: "totalSakuteki")
+ notifyChangeValue(forKey: #keyPath(totalSakuteki))
case "seiku":
- notifyChangeValue(forKey: "totalSeiku")
+ notifyChangeValue(forKey: #keyPath(totalSeiku))
case "totalSeiku":
- notifyChangeValue(forKey: "totalCalclatedSeiku")
+ notifyChangeValue(forKey: #keyPath(totalCalclatedSeiku))
case "lv":
- notifyChangeValue(forKey: "totalLevel")
+ notifyChangeValue(forKey: #keyPath(totalLevel))
case "totalDrums":
- notifyChangeValue(forKey: "totalDrums")
+ notifyChangeValue(forKey: #keyPath(totalDrums))
default: break
}
return
ships = array.flatMap { $0 }
[String]()
- .appended { "totalSakuteki" }
- .appended { "totalSeiku" }
- .appended { "totalCalclatedSeiku" }
- .appended { "totalLevel" }
- .appended { "totalDrums" }
- .appended { "repairable" }
+ .appended { #keyPath(totalSakuteki) }
+ .appended { #keyPath(totalSeiku) }
+ .appended { #keyPath(totalCalclatedSeiku) }
+ .appended { #keyPath(totalLevel) }
+ .appended { #keyPath(totalDrums) }
+ .appended { #keyPath(repairable) }
.forEach { notifyChangeValue(forKey: $0) }
}
}
class ResourceViewController: NSViewController {
class func keyPathsForValuesAffectingShipNumberColor() -> Set<String> {
- return ["maxChara", "shipCount", "minimumColoredShipCount"]
+ return [#keyPath(maxChara), #keyPath(shipCount), #keyPath(minimumColoredShipCount)]
}
let managedObjectContext = ServerDataStore.default.context
deinit {
- unbind("maxChara")
- unbind("shipCount")
+ unbind(#keyPath(maxChara))
+ unbind(#keyPath(shipCount))
}
@IBOutlet var shipController: NSArrayController!
override func viewDidLoad() {
super.viewDidLoad()
- bind("maxChara", to: basicController, withKeyPath: "selection.max_chara", options: nil)
- bind("shipCount", to: shipController, withKeyPath: "arrangedObjects.@count", options: nil)
+ bind(#keyPath(maxChara), to: basicController, withKeyPath: "selection.max_chara", options: nil)
+ bind(#keyPath(shipCount), to: shipController, withKeyPath: "arrangedObjects.@count", options: nil)
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
- damageView.unbind("damageType")
- supply.unbind("shipStatus")
+ damageView.unbind(#keyPath(DamageView.damageType))
+ supply.unbind(#keyPath(SuppliesView.shipStatus))
[slot00Field, slot01Field, slot02Field, slot03Field]
- .forEach { $0?.unbind("slotItemID") }
+ .forEach { $0?.unbind(#keyPath(SlotItemLevelView.slotItemID)) }
}
@IBOutlet weak var supply: SuppliesView!
@IBOutlet weak var guardEscapedView: GuardEscapedView!
@IBOutlet weak var damageView: DamageView!
- @IBOutlet weak var slot00Field: NSTextField!
- @IBOutlet weak var slot01Field: NSTextField!
- @IBOutlet weak var slot02Field: NSTextField!
- @IBOutlet weak var slot03Field: NSTextField!
+ @IBOutlet weak var slot00Field: SlotItemLevelView!
+ @IBOutlet weak var slot01Field: SlotItemLevelView!
+ @IBOutlet weak var slot02Field: SlotItemLevelView!
+ @IBOutlet weak var slot03Field: SlotItemLevelView!
@IBOutlet var shipController: NSObjectController!
dynamic var guardEscaped: Bool = false {
damageView.setFrameOrigin(.zero)
view.addSubview(damageView)
- damageView.bind("damageType", to: shipController, withKeyPath: "selection.status", options: nil)
+ damageView.bind(#keyPath(DamageView.damageType),
+ to: shipController,
+ withKeyPath: "selection.status", options: nil)
- supply.bind("shipStatus", to: shipController, withKeyPath: "selection.self", options: nil)
+ supply.bind(#keyPath(SuppliesView.shipStatus),
+ to: shipController,
+ withKeyPath: "selection.self", options: nil)
guardEscapedView.setFrameOrigin(.zero)
view.addSubview(guardEscapedView)
let fields = [slot00Field, slot01Field, slot02Field, slot03Field]
let keypath = ["selection.slot_0", "selection.slot_1", "selection.slot_2", "selection.slot_3"]
zip(fields, keypath).forEach {
- $0.0?.bind("slotItemID", to: shipController, withKeyPath: $0.1, options: nil)
+ $0.0?.bind(#keyPath(SlotItemLevelView.slotItemID), to: shipController, withKeyPath: $0.1, options: nil)
}
}
}
}
shipController.sortDescriptors = UserDefaults.standard.shipviewSortDescriptors
shipController.addObserver(self, forKeyPath: NSSortDescriptorsBinding, context: nil)
- shipController.addObserver(self, forKeyPath: "arrangedObjects", context: nil)
+ shipController.addObserver(self, forKeyPath: #keyPath(shipController.arrangedObjects), context: nil)
let tableViews = [expTableView, powerTableView, power2TableView, power3TableView]
tableViews
UserDefaults.standard.shipviewSortDescriptors = shipController.sortDescriptors
return
}
- if keyPath == "arrangedObjects" {
- notifyChangeValue(forKey: "standardDeviation")
+ if keyPath == #keyPath(shipController.arrangedObjects) {
+ notifyChangeValue(forKey: #keyPath(standardDeviation))
return
}
override init(frame frameRect: NSRect) {
slotItemController = NSObjectController()
super.init(frame: frameRect)
- self.bind("slotItemLevel", to: slotItemController, withKeyPath: "selection.level", options: nil)
- self.bind("slotItemAlv", to: slotItemController, withKeyPath: "selection.alv", options: nil)
+ bind(#keyPath(slotItemLevel), to: slotItemController, withKeyPath: "selection.level", options: nil)
+ bind(#keyPath(slotItemAlv), to: slotItemController, withKeyPath: "selection.alv", options: nil)
}
required init?(coder: NSCoder) {
slotItemController = NSObjectController()
super.init(coder: coder)
- self.bind("slotItemLevel", to: slotItemController, withKeyPath: "selection.level", options: nil)
- self.bind("slotItemAlv", to: slotItemController, withKeyPath: "selection.alv", options: nil)
+ bind(#keyPath(slotItemLevel), to: slotItemController, withKeyPath: "selection.level", options: nil)
+ bind(#keyPath(slotItemAlv), to: slotItemController, withKeyPath: "selection.alv", options: nil)
}
deinit {
- self.unbind("slotItemLevel")
- self.unbind("slotItemAlv")
+ unbind(#keyPath(slotItemLevel))
+ unbind(#keyPath(slotItemAlv))
}
// MARK: - Variable
var showEquipmentType: Int {
get { return UserDefaults.standard.showEquipmentType.rawValue }
set {
- notifyChangeValue(forKey: "showEquipmentTypeTitle") {
+ notifyChangeValue(forKey: #keyPath(showEquipmentTypeTitle)) {
UserDefaults.standard.showEquipmentType = ShowType(rawValue: newValue) ?? .all
}
slotItemController.fetchPredicate = filterPredicate
class StrengthenListItemCellView: NSTableCellView {
class func keyPathsForValuesAffectingSecondsShipList() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingRequiredEquipment01() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingRequiredEquipment02() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingRequiredEquipment03() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingTargetEquipment() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingRemodelEquipment() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingNeedsScrewString01() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingNeedsScrewString02() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
class func keyPathsForValuesAffectingNeedsScrewString03() -> Set<String> {
- return ["objectValue"]
+ return [#keyPath(objectValue)]
}
private var item: StrengthenListEnhancementItem? {
fileprivate var pShipStatusContext: Int = 0
class SuppliesView: NSControl {
- private let observeKeys = ["fuel", "maxFuel", "bull", "maxBull"]
+ private let observeKeys = [ #keyPath(Ship.fuel),
+ #keyPath(Ship.maxFuel),
+ #keyPath(Ship.bull),
+ #keyPath(Ship.maxBull)]
private let suppliesCell: SuppliesCell
override init(frame: NSRect) {
override init() {
super.init()
registerTimer()
- self.bind("notifyTimeBeforeTimeSignal",
+ self.bind(#keyPath(notifyTimeBeforeTimeSignal),
to: udController,
withKeyPath: "values.notifyTimeBeforeTimeSignal")
}
deinit {
- self.unbind("notifyTimeBeforeTimeSignal")
+ self.unbind(#keyPath(notifyTimeBeforeTimeSignal))
}
dynamic var notifyTimeBeforeTimeSignal: Int = 0 {
}
class func keyPathsForValuesAffectingFilterPredicate() -> Set<String> {
- return ["showLevelOneShipInUpgradableList", "showsExcludedShipInUpgradableList"]
+ return [#keyPath(showLevelOneShipInUpgradableList), #keyPath(showsExcludedShipInUpgradableList)]
}
private var excludeShiIDsCache: [Int] {
var excludeShiIDs: [Int] {
get { return (NSArray(contentsOf: excludeShipIDsSaveURL) as? [Int]) ?? [] }
set {
- notifyChangeValue(forKey: "filterPredicate") {
+ notifyChangeValue(forKey: #keyPath(filterPredicate)) {
(newValue as NSArray).write(to: excludeShipIDsSaveURL, atomically: true)
UpgradableShipsWindowController.excludeShiIDsCache = newValue
}