KMCommonDefine.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // KMCommonDefine.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/3/28.
  6. //
  7. import Foundation
  8. /*  KMCommonDefine [共用的定义] 
  9. ** 用于定义一些共用的函数、共用的通知名称、其他
  10. */
  11. // MARK: - 共用的函数
  12. public func KMPrint(_ items: Any..., separator: String = " ", terminator: String = "\n") {
  13. #if DEBUG
  14. print(items, separator: separator, terminator: terminator)
  15. #endif
  16. }
  17. public func km_synchronized<T>(_ lock: AnyObject, _ body: () throws -> T) rethrows -> T {
  18. objc_sync_enter(lock)
  19. defer { objc_sync_exit(lock) }
  20. return try body()
  21. }
  22. // MARK: - 共用的通知名称
  23. // MARK: - 共用的Block
  24. typealias KMItemClickBlock<T> = (_ item: T?, _ index: Int)->()
  25. typealias KMCommonClickBlock = (_ index: Int, _ params: Any...)->()
  26. typealias KMCommonBlock = (_ params: Any...)->()
  27. typealias KMEmptyBlock = ()->Void
  28. typealias KMValueDidChangeBlock = (_ value: Any?, _ change: [NSKeyValueChangeKey : Any]?)->()
  29. typealias KMResultBlock = (_ result: KMResult?, _ params: Any...)->Void
  30. // MARK: - 其他
  31. let kKMLocalForDraggedTypes = NSPasteboard.PasteboardType(rawValue: "KMLocalForDraggedTypes")
  32. let kKMMainMenuAccountRefreshItemTag = 16