From 3efee63d411084a1bf54356cfd41861bc3637ec5 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 30 May 2023 14:24:35 -0500 Subject: [PATCH] [AltStoreCore] Makes AppPermission.usageDescription non-optional for backwards compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../AltStore 13.xcdatamodel/contents | 2 +- AltStoreCore/Model/AppPermission.swift | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 13.xcdatamodel/contents b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 13.xcdatamodel/contents index c80ebb34..e99bcc3e 100644 --- a/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 13.xcdatamodel/contents +++ b/AltStoreCore/Model/AltStore.xcdatamodeld/AltStore 13.xcdatamodel/contents @@ -30,7 +30,7 @@ - + diff --git a/AltStoreCore/Model/AppPermission.swift b/AltStoreCore/Model/AppPermission.swift index d1a80804..6b220351 100644 --- a/AltStoreCore/Model/AppPermission.swift +++ b/AltStoreCore/Model/AppPermission.swift @@ -16,7 +16,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