From 7727a0b725e41c1fa7c39bd8d24f2bf9675825e7 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Wed, 31 Jul 2019 14:07:00 -0700 Subject: [PATCH] [AltStore] Renames App to StoreApp --- .../App Detail/AppContentViewController.swift | 2 +- AltStore/App Detail/AppViewController.swift | 4 +- AltStore/AppDelegate.swift | 2 +- AltStore/Browse/BrowseViewController.swift | 14 +-- AltStore/Managing Apps/AppManager.swift | 2 +- .../AltStore.xcdatamodel/contents | 86 +++++++++---------- AltStore/Model/App.swift | 22 ++--- AltStore/Model/AppPermission.swift | 2 +- AltStore/Model/DatabaseManager.swift | 8 +- AltStore/Model/InstalledApp.swift | 8 +- AltStore/Model/MergePolicy.swift | 2 +- AltStore/Model/Source.swift | 6 +- AltStore/My Apps/MyAppsViewController.swift | 2 +- AltStore/Operations/ResignAppOperation.swift | 2 +- AltStore/Protocols/AppProtocol.swift | 2 +- 15 files changed, 82 insertions(+), 82 deletions(-) diff --git a/AltStore/App Detail/AppContentViewController.swift b/AltStore/App Detail/AppContentViewController.swift index 79643687..5f0a8f81 100644 --- a/AltStore/App Detail/AppContentViewController.swift +++ b/AltStore/App Detail/AppContentViewController.swift @@ -24,7 +24,7 @@ extension AppContentViewController class AppContentViewController: UITableViewController { - var app: App! + var app: StoreApp! private lazy var screenshotsDataSource = self.makeScreenshotsDataSource() private lazy var permissionsDataSource = self.makePermissionsDataSource() diff --git a/AltStore/App Detail/AppViewController.swift b/AltStore/App Detail/AppViewController.swift index d5c38871..4d7ed647 100644 --- a/AltStore/App Detail/AppViewController.swift +++ b/AltStore/App Detail/AppViewController.swift @@ -12,7 +12,7 @@ import Roxas class AppViewController: UIViewController { - var app: App! + var app: StoreApp! private var contentViewController: AppContentViewController! private var contentViewControllerShadowView: UIView! @@ -321,7 +321,7 @@ class AppViewController: UIViewController extension AppViewController { - class func makeAppViewController(app: App) -> AppViewController + class func makeAppViewController(app: StoreApp) -> AppViewController { let storyboard = UIStoryboard(name: "Main", bundle: nil) diff --git a/AltStore/AppDelegate.swift b/AltStore/AppDelegate.swift index 46e32484..4f6062db 100644 --- a/AltStore/AppDelegate.swift +++ b/AltStore/AppDelegate.swift @@ -294,7 +294,7 @@ private extension AppDelegate let group = AppManager.shared.refresh(filteredApps, presentingViewController: nil) group.beginInstallationHandler = { (installedApp) in - guard installedApp.bundleIdentifier == App.altstoreAppID else { return } + guard installedApp.bundleIdentifier == StoreApp.altstoreAppID else { return } // We're starting to install AltStore, which means the app is about to quit. // So, we schedule a "refresh successful" local notification to be displayed after a delay, diff --git a/AltStore/Browse/BrowseViewController.swift b/AltStore/Browse/BrowseViewController.swift index 5bb83101..13f6f25f 100644 --- a/AltStore/Browse/BrowseViewController.swift +++ b/AltStore/Browse/BrowseViewController.swift @@ -54,22 +54,22 @@ class BrowseViewController: UICollectionViewController private extension BrowseViewController { - func makeDataSource() -> RSTFetchedResultsCollectionViewPrefetchingDataSource + func makeDataSource() -> RSTFetchedResultsCollectionViewPrefetchingDataSource { - let fetchRequest = App.fetchRequest() as NSFetchRequest - fetchRequest.sortDescriptors = [NSSortDescriptor(keyPath: \App.sortIndex, ascending: true), NSSortDescriptor(keyPath: \App.name, ascending: true)] + let fetchRequest = StoreApp.fetchRequest() as NSFetchRequest + fetchRequest.sortDescriptors = [NSSortDescriptor(keyPath: \StoreApp.sortIndex, ascending: true), NSSortDescriptor(keyPath: \StoreApp.name, ascending: true)] fetchRequest.returnsObjectsAsFaults = false if let source = Source.fetchAltStoreSource(in: DatabaseManager.shared.viewContext) { - fetchRequest.predicate = NSPredicate(format: "%K != %@ AND %K == %@", #keyPath(App.bundleIdentifier), App.altstoreAppID, #keyPath(App.source), source) + fetchRequest.predicate = NSPredicate(format: "%K != %@ AND %K == %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID, #keyPath(StoreApp.source), source) } else { - fetchRequest.predicate = NSPredicate(format: "%K != %@", #keyPath(App.bundleIdentifier), App.altstoreAppID) + fetchRequest.predicate = NSPredicate(format: "%K != %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID) } - let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext) + let dataSource = RSTFetchedResultsCollectionViewPrefetchingDataSource(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext) dataSource.cellConfigurationHandler = { (cell, app, indexPath) in let cell = cell as! BrowseCollectionViewCell cell.nameLabel.text = app.name @@ -145,7 +145,7 @@ private extension BrowseViewController } } - func install(_ app: App, at indexPath: IndexPath) + func install(_ app: StoreApp, at indexPath: IndexPath) { let previousProgress = AppManager.shared.installationProgress(for: app) guard previousProgress == nil else { diff --git a/AltStore/Managing Apps/AppManager.swift b/AltStore/Managing Apps/AppManager.swift index 3ff5a7c2..007d55c6 100644 --- a/AltStore/Managing Apps/AppManager.swift +++ b/AltStore/Managing Apps/AppManager.swift @@ -277,7 +277,7 @@ private extension AppManager if let installedApp = result.value { - if let app = app as? App, let storeApp = installedApp.managedObjectContext?.object(with: app.objectID) as? App + if let app = app as? StoreApp, let storeApp = installedApp.managedObjectContext?.object(with: app.objectID) as? StoreApp { installedApp.storeApp = storeApp } diff --git a/AltStore/Model/AltStore.xcdatamodeld/AltStore.xcdatamodel/contents b/AltStore/Model/AltStore.xcdatamodeld/AltStore.xcdatamodel/contents index 8785dc96..ebabb1e6 100644 --- a/AltStore/Model/AltStore.xcdatamodeld/AltStore.xcdatamodel/contents +++ b/AltStore/Model/AltStore.xcdatamodeld/AltStore.xcdatamodel/contents @@ -13,7 +13,48 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -37,47 +78,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -92,7 +92,7 @@ - + diff --git a/AltStore/Model/App.swift b/AltStore/Model/App.swift index 7064fe7e..d6c0066f 100644 --- a/AltStore/Model/App.swift +++ b/AltStore/Model/App.swift @@ -1,5 +1,5 @@ // -// App.swift +// StoreApp.swift // AltStore // // Created by Riley Testut on 5/20/19. @@ -12,13 +12,13 @@ import CoreData import Roxas import AltSign -extension App +extension StoreApp { static let altstoreAppID = "com.rileytestut.AltStore" } -@objc(App) -class App: NSManagedObject, Decodable, Fetchable +@objc(StoreApp) +class StoreApp: NSManagedObject, Decodable, Fetchable { /* Properties */ @NSManaged private(set) var name: String @@ -77,7 +77,7 @@ class App: NSManagedObject, Decodable, Fetchable { guard let context = decoder.managedObjectContext else { preconditionFailure("Decoder must have non-nil NSManagedObjectContext.") } - super.init(entity: App.entity(), insertInto: nil) + super.init(entity: StoreApp.entity(), insertInto: nil) let container = try decoder.container(keyedBy: CodingKeys.self) self.name = try container.decode(String.self, forKey: .name) @@ -116,18 +116,18 @@ class App: NSManagedObject, Decodable, Fetchable } } -extension App +extension StoreApp { - @nonobjc class func fetchRequest() -> NSFetchRequest + @nonobjc class func fetchRequest() -> NSFetchRequest { - return NSFetchRequest(entityName: "App") + return NSFetchRequest(entityName: "StoreApp") } - class func makeAltStoreApp(in context: NSManagedObjectContext) -> App + class func makeAltStoreApp(in context: NSManagedObjectContext) -> StoreApp { - let app = App(context: context) + let app = StoreApp(context: context) app.name = "AltStore" - app.bundleIdentifier = App.altstoreAppID + app.bundleIdentifier = StoreApp.altstoreAppID app.developerName = "Riley Testut" app.localizedDescription = "AltStore is an alternative App Store." app.iconName = "" diff --git a/AltStore/Model/AppPermission.swift b/AltStore/Model/AppPermission.swift index 7dc75373..507ed25b 100644 --- a/AltStore/Model/AppPermission.swift +++ b/AltStore/Model/AppPermission.swift @@ -50,7 +50,7 @@ class AppPermission: NSManagedObject, Decodable, Fetchable @NSManaged var usageDescription: String /* Relationships */ - @NSManaged private(set) var app: App! + @NSManaged private(set) var app: StoreApp! private override init(entity: NSEntityDescription, insertInto context: NSManagedObjectContext?) { diff --git a/AltStore/Model/DatabaseManager.swift b/AltStore/Model/DatabaseManager.swift index 67e53d5b..c440e4ba 100644 --- a/AltStore/Model/DatabaseManager.swift +++ b/AltStore/Model/DatabaseManager.swift @@ -125,9 +125,9 @@ private extension DatabaseManager context.performAndWait { guard let localApp = ALTApplication(fileURL: Bundle.main.bundleURL) else { return } - let storeApp: App + let storeApp: StoreApp - if let app = App.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(App.bundleIdentifier), App.altstoreAppID), in: context) + if let app = StoreApp.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(StoreApp.bundleIdentifier), StoreApp.altstoreAppID), in: context) { storeApp = app } @@ -135,7 +135,7 @@ private extension DatabaseManager { let source = Source.makeAltStoreSource(in: context) - storeApp = App.makeAltStoreApp(in: context) + storeApp = StoreApp.makeAltStoreApp(in: context) storeApp.version = localApp.version storeApp.source = source } @@ -148,7 +148,7 @@ private extension DatabaseManager } else { - installedApp = InstalledApp(resignedApp: localApp, originalBundleIdentifier: App.altstoreAppID, context: context) + installedApp = InstalledApp(resignedApp: localApp, originalBundleIdentifier: StoreApp.altstoreAppID, context: context) installedApp.storeApp = storeApp } diff --git a/AltStore/Model/InstalledApp.swift b/AltStore/Model/InstalledApp.swift index 4df25687..6c5f2003 100644 --- a/AltStore/Model/InstalledApp.swift +++ b/AltStore/Model/InstalledApp.swift @@ -24,7 +24,7 @@ class InstalledApp: NSManagedObject, Fetchable @NSManaged var expirationDate: Date /* Relationships */ - @NSManaged var storeApp: App? + @NSManaged var storeApp: StoreApp? var isSideloaded: Bool { return self.storeApp == nil @@ -74,7 +74,7 @@ extension InstalledApp class func fetchAltStore(in context: NSManagedObjectContext) -> InstalledApp? { - let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) + let predicate = NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID) let altStore = InstalledApp.first(satisfying: predicate, in: context) return altStore @@ -82,7 +82,7 @@ extension InstalledApp class func fetchAppsForRefreshingAll(in context: NSManagedObjectContext) -> [InstalledApp] { - let predicate = NSPredicate(format: "%K != %@", #keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) + let predicate = NSPredicate(format: "%K != %@", #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID) var installedApps = InstalledApp.all(satisfying: predicate, sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)], @@ -103,7 +103,7 @@ extension InstalledApp let predicate = NSPredicate(format: "(%K < %@) AND (%K != %@)", #keyPath(InstalledApp.refreshedDate), date as NSDate, - #keyPath(InstalledApp.bundleIdentifier), App.altstoreAppID) + #keyPath(InstalledApp.bundleIdentifier), StoreApp.altstoreAppID) var installedApps = InstalledApp.all(satisfying: predicate, sortedBy: [NSSortDescriptor(keyPath: \InstalledApp.expirationDate, ascending: true)], diff --git a/AltStore/Model/MergePolicy.swift b/AltStore/Model/MergePolicy.swift index e7516231..4f0491df 100644 --- a/AltStore/Model/MergePolicy.swift +++ b/AltStore/Model/MergePolicy.swift @@ -23,7 +23,7 @@ open class MergePolicy: RSTRelationshipPreservingMergePolicy { switch conflict.databaseObject { - case let databaseObject as App: + case let databaseObject as StoreApp: // Delete previous permissions for permission in databaseObject.permissions { diff --git a/AltStore/Model/Source.swift b/AltStore/Model/Source.swift index f28d4242..37f5a855 100644 --- a/AltStore/Model/Source.swift +++ b/AltStore/Model/Source.swift @@ -24,9 +24,9 @@ class Source: NSManagedObject, Fetchable, Decodable /* Relationships */ @objc(apps) @NSManaged private(set) var _apps: NSOrderedSet - @nonobjc var apps: [App] { + @nonobjc var apps: [StoreApp] { get { - return self._apps.array as! [App] + return self._apps.array as! [StoreApp] } set { self._apps = NSOrderedSet(array: newValue) @@ -57,7 +57,7 @@ class Source: NSManagedObject, Fetchable, Decodable self.identifier = try container.decode(String.self, forKey: .identifier) self.sourceURL = try container.decode(URL.self, forKey: .sourceURL) - let apps = try container.decodeIfPresent([App].self, forKey: .apps) ?? [] + let apps = try container.decodeIfPresent([StoreApp].self, forKey: .apps) ?? [] for (index, app) in apps.enumerated() { app.sortIndex = Int32(index) diff --git a/AltStore/My Apps/MyAppsViewController.swift b/AltStore/My Apps/MyAppsViewController.swift index 66f4b1d5..9ed257b6 100644 --- a/AltStore/My Apps/MyAppsViewController.swift +++ b/AltStore/My Apps/MyAppsViewController.swift @@ -339,7 +339,7 @@ private extension MyAppsViewController } } - if installedApps.contains(where: { $0.bundleIdentifier == App.altstoreAppID }) + if installedApps.contains(where: { $0.bundleIdentifier == StoreApp.altstoreAppID }) { let alertController = UIAlertController(title: NSLocalizedString("Refresh AltStore?", comment: ""), message: NSLocalizedString("AltStore will quit when it is finished refreshing.", comment: ""), preferredStyle: .alert) alertController.addAction(UIAlertAction(title: RSTSystemLocalizedString("Cancel"), style: .cancel) { (action) in diff --git a/AltStore/Operations/ResignAppOperation.swift b/AltStore/Operations/ResignAppOperation.swift index 0cfbb5f1..5eb3d05f 100644 --- a/AltStore/Operations/ResignAppOperation.swift +++ b/AltStore/Operations/ResignAppOperation.swift @@ -395,7 +395,7 @@ private extension ResignAppOperation var additionalValues: [String: Any] = [Bundle.Info.urlTypes: allURLSchemes] - if self.context.bundleIdentifier == App.altstoreAppID + if self.context.bundleIdentifier == StoreApp.altstoreAppID { guard let udid = Bundle.main.object(forInfoDictionaryKey: Bundle.Info.deviceID) as? String else { throw OperationError.unknownUDID } additionalValues[Bundle.Info.deviceID] = udid diff --git a/AltStore/Protocols/AppProtocol.swift b/AltStore/Protocols/AppProtocol.swift index fa331fe8..4d1a640f 100644 --- a/AltStore/Protocols/AppProtocol.swift +++ b/AltStore/Protocols/AppProtocol.swift @@ -23,7 +23,7 @@ extension ALTApplication: AppProtocol } } -extension App: AppProtocol +extension StoreApp: AppProtocol { var url: URL { return self.downloadURL