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
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)
+ }
}
}
}