KMPageEditSettingBaseView.swift 841 B

12345678910111213141516171819202122232425262728
  1. //
  2. // KMPageEditSettingBaseView.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/1/12.
  6. //
  7. import Cocoa
  8. typealias KMPageEditSettingViewItemClick = (_ index: Int, _ value: Any) -> ()
  9. class KMPageEditSettingBaseView: NSView, NibLoadable {
  10. var itemClick: KMPageEditSettingViewItemClick?
  11. static var nibName: String? {
  12. return "KMPageEditSettingBaseWindowController"
  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. }