KMRedactContentBaseView.swift 812 B

123456789101112131415161718192021222324252627
  1. //
  2. // KMRedactContentBaseView.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/1/17.
  6. //
  7. import Cocoa
  8. typealias KMRedactContentItemClick = (_ index: Int, _ value: Any?) -> ()
  9. class KMRedactContentBaseView: NSView, NibLoadable {
  10. var itemClick: KMRedactContentItemClick?
  11. static var nibName: String? {
  12. return "KMRedactBaseWindowController"
  13. }
  14. static func createFromNib(in bundle: Bundle = Bundle.main) -> Self? {
  15. guard let nibName = nibName else { return nil }
  16. var topLevelArray: NSArray? = nil
  17. bundle.loadNibNamed(NSNib.Name(nibName), owner: nil, topLevelObjects: &topLevelArray)
  18. guard let results = topLevelArray else { return nil }
  19. let views = Array<Any>(results).filter { $0 is Self }
  20. return views.last as? Self
  21. }
  22. }