OSDN Git Service

艦隊ステータスなどが正しく反映されていなかった問題を修正
authormasakih <masakih@users.sourceforge.jp>
Sun, 1 Jan 2017 16:32:06 +0000 (01:32 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 1 Jan 2017 16:32:06 +0000 (01:32 +0900)
KCD/HMFleetViewController.swift

index a0391bd..5e6b295 100644 (file)
@@ -168,7 +168,7 @@ class HMFleetViewController: NSViewController {
         get { return ships.reduce(0) { $0 + ($1.totalDrums as Int) } }
     }
     
-    var fleet: HMKCDeck? {
+    dynamic var fleet: HMKCDeck? {
         get {
             guard let f = representedObject as? HMKCDeck else { return nil }
             return f
@@ -184,13 +184,17 @@ class HMFleetViewController: NSViewController {
     private let shipObserveKeys: [String] = ["sakuteki_0", "seiku", "lv", "totalDrums"]
     fileprivate var ships: [HMKCShipObject] = [] {
         willSet {
-            zip(ships, shipObserveKeys).forEach {
-                $0.0.removeObserver(self, forKeyPath:$0.1)
+            ships.forEach { (ship) in
+                shipObserveKeys.forEach {
+                    ship.removeObserver(self, forKeyPath: $0)
+                }
             }
         }
         didSet {
-            zip(ships, shipObserveKeys).forEach {
-                $0.0.addObserver(self, forKeyPath: $0.1, options: NSKeyValueObservingOptions(rawValue: 0), context: &shipsContext)
+            ships.forEach { (ship) in
+                shipObserveKeys.forEach {
+                    ship.addObserver(self, forKeyPath: $0, options: [], context: &shipsContext)
+                }
             }
         }
     }