TSUserDefaultData.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // TSUserDefaultData.swift
  3. // AIRingtone
  4. //
  5. // Created by 100Years on 2025/3/5.
  6. //
  7. import ObjectMapper
  8. //海报历史记录
  9. class TSPosterHistory{
  10. @UserDefault(key: "kPosterTextPicHistoryListString", defaultValue: "")
  11. static private var historyString: String
  12. static var listModelArray: [TSGeneralPicModel] = {
  13. if let listModelArray = Mapper<TSGeneralPicModel>().mapArray(JSONString: historyString){
  14. return listModelArray
  15. }
  16. return []
  17. }()
  18. static func saveModel(model:TSGeneralPicModel){
  19. listModelArray.insert(model, at: 0)
  20. if let jsonString = listModelArray.toJSONString() {
  21. historyString = jsonString
  22. }
  23. }
  24. }
  25. //头像历史记录
  26. class TSPhotoHistory{
  27. @UserDefault(key: "kPhotoTextPicHistoryListString", defaultValue: "")
  28. static private var historyString: String
  29. static var listModelArray: [TSGeneralPicModel] = {
  30. if let listModelArray = Mapper<TSGeneralPicModel>().mapArray(JSONString: historyString){
  31. return listModelArray
  32. }
  33. return []
  34. }()
  35. static func saveModel(model:TSGeneralPicModel){
  36. listModelArray.insert(model, at: 0)
  37. if let jsonString = listModelArray.toJSONString() {
  38. historyString = jsonString
  39. }
  40. }
  41. }