[AltStoreCore] Adds StoreApp.category + StoreCategory enum

This commit is contained in:
Riley Testut
2023-12-07 18:04:48 -06:00
committed by Magesh K
parent 71eb77cfda
commit 1b8daa59c0
4 changed files with 84 additions and 3 deletions

View File

@@ -115,6 +115,14 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
@NSManaged public private(set) var localizedDescription: String
@NSManaged @objc(size) internal var _size: Int32
@nonobjc public var category: StoreCategory? {
guard let _category else { return nil }
let category = StoreCategory(rawValue: _category)
return category
}
@NSManaged @objc(category) public private(set) var _category: String?
@NSManaged public private(set) var iconURL: URL
@NSManaged public private(set) var screenshotURLs: [URL]
@@ -259,6 +267,7 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
case isBeta = "beta"
case versions
case patreon
case category
// Legacy
case version
@@ -282,10 +291,10 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)
self.developerName = try container.decode(String.self, forKey: .developerName)
self.localizedDescription = try container.decode(String.self, forKey: .localizedDescription)
self.iconURL = try container.decode(URL.self, forKey: .iconURL)
self.subtitle = try container.decodeIfPresent(String.self, forKey: .subtitle)
self.iconURL = try container.decode(URL.self, forKey: .iconURL)
self.isBeta = try container.decodeIfPresent(Bool.self, forKey: .isBeta) ?? false
var downloadURL = try container.decodeIfPresent(URL.self, forKey: .downloadURL)
let platformURLs = try container.decodeIfPresent(PlatformURLs.self.self, forKey: .platformURLs)
@@ -329,7 +338,10 @@ public class StoreApp: NSManagedObject, Decodable, Fetchable
self.tintColor = tintColor
}
self.isBeta = try container.decodeIfPresent(Bool.self, forKey: .isBeta) ?? false
if let rawCategory = try container.decodeIfPresent(String.self, forKey: .category)
{
self._category = rawCategory.lowercased() // Store raw (lowercased) category value.
}
let appScreenshots: [AppScreenshot]