make AppDelegate a bit swifty

This commit is contained in:
Jesús A. Álvarez 2024-02-10 13:36:20 +01:00
parent 3b96faf502
commit 22256824d2
4 changed files with 7 additions and 7 deletions

View File

@ -23,8 +23,8 @@ extern NSString *DocumentsChangedNotification;
@property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed; @property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed;
@property (readonly, nonatomic) id<Emulator> sharedEmulator; @property (readonly, nonatomic) id<Emulator> sharedEmulator;
+ (instancetype)sharedInstance; @property (class, readonly, strong) AppDelegate *sharedInstance NS_SWIFT_NAME(shared);
+ (id<Emulator>)sharedEmulator; @property (class, readonly, strong) id<Emulator> sharedEmulator NS_SWIFT_NAME(emulator);
- (void)loadAndStartEmulator; - (void)loadAndStartEmulator;
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message; - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message;

View File

@ -15,7 +15,7 @@ class DefaultSceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = scene as? UIWindowScene else { guard let windowScene = scene as? UIWindowScene else {
fatalError("Expected scene of type UIWindowScene but got an unexpected type") fatalError("Expected scene of type UIWindowScene but got an unexpected type")
} }
guard let appDelegate = AppDelegate.sharedInstance() else { guard let appDelegate = AppDelegate.shared else {
fatalError("No app delegate") fatalError("No app delegate")
} }

View File

@ -15,7 +15,7 @@ class KeyboardSceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = scene as? UIWindowScene else { guard let windowScene = scene as? UIWindowScene else {
fatalError("Expected scene of type UIWindowScene but got an unexpected type") fatalError("Expected scene of type UIWindowScene but got an unexpected type")
} }
guard let mainViewController = AppDelegate.sharedInstance().window.rootViewController as? ViewController else { guard let mainViewController = AppDelegate.shared.window.rootViewController as? ViewController else {
fatalError("No main view controller") fatalError("No main view controller")
} }

View File

@ -21,13 +21,13 @@ extension ViewController {
Spacer(minLength: 80.0) Spacer(minLength: 80.0)
HStack { HStack {
Button(action: { Button(action: {
AppDelegate.sharedInstance().showSettings(self) AppDelegate.shared.showSettings(self)
}, label: { }, label: {
Image(systemName: "gear") Image(systemName: "gear")
}).glassBackgroundEffect() }).glassBackgroundEffect()
Button(action: { Button(action: {
AppDelegate.sharedInstance().showInsertDisk(self) AppDelegate.shared.showInsertDisk(self)
}, label: { }, label: {
Image(systemName: "opticaldiscdrive") Image(systemName: "opticaldiscdrive")
}).glassBackgroundEffect() }).glassBackgroundEffect()
@ -46,7 +46,7 @@ extension ViewController {
@objc @objc
static func adjustToScreenSize() { static func adjustToScreenSize() {
let screenSize = AppDelegate.sharedEmulator().screenSize let screenSize = AppDelegate.emulator.screenSize
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
return return
} }