5 // Created by Hori,Masaki on 2017/01/02.
6 // Copyright © 2017年 Hori,Masaki. All rights reserved.
11 fileprivate var ShipStatusContext: Int = 0
13 class SuppliesView: NSControl {
14 private let observeKeys = ["fuel", "maxFuel", "bull", "maxBull"]
15 private let suppliesCell: SuppliesCell
17 override init(frame: NSRect) {
18 suppliesCell = SuppliesCell()
19 super.init(frame: frame)
20 self.cell = suppliesCell
22 required init?(coder: NSCoder) {
23 suppliesCell = SuppliesCell()
24 super.init(coder: coder)
25 self.cell = suppliesCell
29 suppliesCell.shipStatus?.removeObserver(self, forKeyPath: $0)
33 var shipStatus: KCShipObject? {
35 return suppliesCell.shipStatus
39 suppliesCell.shipStatus?.removeObserver(self, forKeyPath: $0)
41 suppliesCell.shipStatus = newValue
43 suppliesCell.shipStatus?.addObserver(self, forKeyPath: $0, context: &ShipStatusContext)
49 override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
50 if context == &ShipStatusContext {
54 super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)