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)
16 @IBOutlet var imageView: ImageView!
18 override var nibName: String! {
19 return "ScreenshotDetailViewController"
21 override var contentRect: NSRect {
22 return imageView.convert(imageView.imageRect, to: nil)
25 private var currentSelection: [ScreenshotInformation] = []
27 override func viewDidLoad() {
30 arrayController.addObserver(self, forKeyPath: NSSelectionIndexesBinding, context: nil)
34 override func observeValue(forKeyPath keyPath: String?,
36 change: [NSKeyValueChangeKey: Any]?,
37 context: UnsafeMutableRawPointer?) {
38 if keyPath == NSSelectionIndexesBinding {
43 super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
46 private func updateSelections() {
47 guard let selection = arrayController.selectedObjects as? [ScreenshotInformation]
49 if currentSelection == selection { return }
50 imageView.images = selection.flatMap { NSImage(contentsOf: $0.url) }
51 currentSelection = selection