2 // ScreenshotDetailViewController.swift
5 // Created by Hori,Masaki on 2016/12/29.
6 // Copyright © 2016年 Hori,Masaki. All rights reserved.
11 final class ScreenshotDetailViewController: BridgeViewController {
15 arrayController.removeObserver(self, forKeyPath: NSBindingName.selectionIndexes.rawValue)
18 @IBOutlet var imageView: ImageView!
20 override var nibName: NSNib.Name {
22 return .nibName(instanceOf: self)
25 override var contentRect: NSRect {
27 return imageView.convert(imageView.imageRect, to: nil)
30 private var currentSelection: [ScreenshotInformation] = []
32 override func viewDidLoad() {
36 arrayController.addObserver(self, forKeyPath: NSBindingName.selectionIndexes.rawValue, context: nil)
40 override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
42 if keyPath == NSBindingName.selectionIndexes.rawValue {
49 super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
52 private func updateSelections() {
54 guard let selection = arrayController.selectedObjects as? [ScreenshotInformation] else { return }
56 if currentSelection == selection { return }
58 imageView.images = selection.flatMap { NSImage(contentsOf: $0.url) }
59 currentSelection = selection