KMBotaTools.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. class func noteFilterStates(key: String) -> [NSNumber] {
  38. if let data = KMDataManager.ud_object(forKey: NoteFilterVC.filterSelectStateKey + key) as? Data {
  39. return (NSKeyedUnarchiver.unarchiveObject(with: data) as? [NSNumber]) ?? []
  40. }
  41. return []
  42. }
  43. }