KMBotaTools.swift 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // KMBotaTools.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2024/3/23.
  6. //
  7. import Cocoa
  8. class KMBotaTools: NSObject {
  9. }
  10. // MARK: - Note
  11. extension KMBotaTools {
  12. // filter
  13. class func noteFilterIsEmpty(key: String) -> Bool {
  14. return self.noteFilterAllTypes(key: key).isEmpty
  15. }
  16. class func noteFilterAllTypes(key: String) -> [Any] {
  17. return self.noteFilterAnnoTypes(key: key) + self.noteFilterColors(key: key) + self.noteFilterAuthors(key: key)
  18. }
  19. class func noteFilterAnnoTypes(key: String) -> [String] {
  20. if let data = KMDataManager.ud_object(forKey: NoteFilterVC.filterSelectTypeKey + key) as? Data {
  21. return (NSKeyedUnarchiver.unarchiveObject(with: data) as? [String]) ?? []
  22. }
  23. return []
  24. }
  25. class func noteFilterColors(key: String) -> [Any] {
  26. if let data = KMDataManager.ud_object(forKey: NoteFilterVC.filterSelectColorKey + key) as? Data {
  27. return (NSKeyedUnarchiver.unarchiveObject(with: data) as? [Any]) ?? []
  28. }
  29. return []
  30. }
  31. class func noteFilterAuthors(key: String) -> [String] {
  32. if let data = KMDataManager.ud_object(forKey: NoteFilterVC.filterSelectAuthorKey + key) as? Data {
  33. return (NSKeyedUnarchiver.unarchiveObject(with: data) as? [String]) ?? []
  34. }
  35. return []
  36. }
  37. }