2 // ScreenshotDetailViewController.swift
5 // Created by Hori,Masaki on 2016/12/29.
6 // Copyright © 2016年 Hori,Masaki. All rights reserved.
11 class ScreenshotDetailViewController: BridgeViewController {
13 arrayController.removeObserver(self, forKeyPath: NSSelectionIndexesBinding)
17 @IBOutlet var imageView: ImageView!
19 override var nibName: String! {
20 return "ScreenshotDetailViewController"
22 override var contentRect: NSRect {
23 return imageView.convert(imageView.imageRect, to: nil)
26 private var currentSelection: [ScreenshotInformation] = []
28 override func viewDidLoad() {
31 arrayController.addObserver(self, forKeyPath: NSSelectionIndexesBinding, context: nil)
35 override func observeValue(forKeyPath keyPath: String?,
37 change: [NSKeyValueChangeKey: Any]?,
38 context: UnsafeMutableRawPointer?) {
39 if keyPath == NSSelectionIndexesBinding {
44 super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
47 private func updateSelections() {
48 guard let selection = arrayController.selectedObjects as? [ScreenshotInformation]
50 if currentSelection == selection { return }
51 imageView.images = selection.flatMap { NSImage(contentsOf: $0.url) }
52 currentSelection = selection