[AltStoreCore] Makes AppPermission.usageDescription non-optional for backwards compatibility

Necessary to support switching between AltStore beta and public version.

Wraps private non-optional _usageDescription value in public accessor with optional return type to still treat it as “optional” value.
This commit is contained in:
Riley Testut
2023-05-30 14:24:35 -05:00
committed by Magesh K
parent 5161c506f0
commit 74bccf4caf
2 changed files with 9 additions and 2 deletions

View File

@@ -77,7 +77,14 @@ public class AppPermission: NSManagedObject, Decodable, Fetchable
{
/* Properties */
@NSManaged public var type: ALTAppPermissionType
@NSManaged public var usageDescription: String?
// usageDescription must be non-optional for backwards compatibility,
// so we store non-optional value and provide public accessor with optional return type.
@nonobjc public var usageDescription: String? {
get { _usageDescription.isEmpty ? nil : _usageDescription }
set { _usageDescription = newValue ?? "" }
}
@NSManaged @objc(usageDescription) private var _usageDescription: String
@nonobjc public var permission: any ALTAppPermission {
switch self.type