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: NSSelectionIndexesBinding)
18 @IBOutlet var imageView: ImageView!
20 override var nibName: String! {
22 return "ScreenshotDetailViewController"
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: NSSelectionIndexesBinding, context: nil)
40 override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
42 if keyPath == NSSelectionIndexesBinding {
49 super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
52 private func updateSelections() {
54 guard let selection = arrayController.selectedObjects as? [ScreenshotInformation]
57 if currentSelection == selection { return }
59 imageView.images = selection.flatMap { NSImage(contentsOf: $0.url) }
60 currentSelection = selection