In iOS, the app delegate is responsible for managing the app throughout its lifecycle by responding to events such as launch and termination.
Questions tagged [appdelegate]
2019 questions
475
votes
18 answers
How do I get a reference to the AppDelegate in Swift?
How do I get a reference to AppDelegate in Swift?
Ultimately, I want to use the reference to access the managed object context.

AperioOculus
- 6,641
- 4
- 26
- 37
252
votes
13 answers
iOS - Calling App Delegate method from ViewController
What I am trying to do is click a button (that was created in code) and have it call up a different view controller then have it run a function in the new view controller.
I know it could be done relatively easily in IB but that isn't an option.
An…

Mytheral
- 3,929
- 7
- 34
- 57
92
votes
16 answers
Get device token for push notification
I am working on push notifications. I wrote the following code for fetching a device token.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization…

Jag
- 967
- 1
- 7
- 11
87
votes
11 answers
UIStatusBarStyle not working in Swift
I'm trying to change the Status Bar color in my Swift app to white, but am hitting a brick wall. I have 3 ViewControllers that are each embedded in a NavigationController (could that be the issue? I've already tried to place the code in the…

davidrayowens
- 1,562
- 2
- 13
- 23
79
votes
11 answers
Opening view controller from app delegate using swift
I am trying to create a push notification which determines which view to open according to information obtained from the push.
I have managed to get the information from the push, but I am now struggling to get the view to open
Looking at other…

Lister
- 1,098
- 1
- 9
- 19
71
votes
16 answers
iOS 13: Swift - 'Set application root view controller programmatically' does not work
I have following code in my AppDelegate.swift to setup root view controller for an iOS application. But it does not work. It follows Target structure (defined under General tab) and ignores this code.
(Xcode 11, Swift 5.1, iOS 13)
class AppDelegate:…

Krunal
- 77,632
- 48
- 245
- 261
59
votes
20 answers
NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle
In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error…

Ortensia C.
- 4,666
- 11
- 43
- 70
49
votes
1 answer
No visible @interface for 'RCTBundleURLProvider' declares the selector 'jsBundleURLForBundleRoot:fallbackResource:'
This is the error that i am getting when building the app.
I am getting this error after upgrading my react-native version from 0.66.2 to 0.68.2 in my Appdelegate.mm file.

sakshya73
- 5,570
- 5
- 22
- 41
41
votes
6 answers
AppDelegate, rootViewController and presentViewController
I'm doing the Facebook integration tutorial, I want to show my MainViewViewController if the user has a valid token for the current state otherwise I want to show LoginViewController.
MainViewAppDelegate.m
- (BOOL)application:(UIApplication…

Boris-V
- 437
- 1
- 4
- 15
35
votes
7 answers
Present UIAlertController from AppDelegate
I'm trying to present a UIAlertController from the AppDelegate in my iOS app.
Below is the alert and the present method.
UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage…

Satre
- 1,724
- 2
- 18
- 22
34
votes
10 answers
Black screen after adding SceneDelegate and updating Info.plist
I am currently getting a blank screen with Xcode 11, Target iOS 13.0 (the app works fine with all below versions iOS 12.1 till 12.4), I want to make my App work for both iOS users above 12.1 and also 13.0 currently getting blank screen despite…

Kris RaduhaSt
- 509
- 1
- 5
- 13
33
votes
5 answers
How to convert Objective-C App Delegate to Swift?
I am working on old projects converting all classes to Swift.
How can I convert the AppDelegate class to Swift?
What changes must me made in the Project settings or main.m?

NSLog
- 649
- 1
- 5
- 12
32
votes
1 answer
Swift 4 ,must be used from main thread only warning
When I using Swift4in Xcode 9 gives me
UIApplication.delegate must be used from main thread only
.... must be used from main thread only
UI API called from background thread Group
Purple Warning.
My codes;
var appDelegate =…

SwiftDeveloper
- 7,244
- 14
- 56
- 85
31
votes
6 answers
Controlling which view controller loads after receiving a push notification in SWIFT
Once I receive a push notification and swipe to open it, it just opens my app and not the VC I want.
So my question is how do I load the VC I want? I know if the app is open I would move the VC over to another inside the didReceiveRemoteNotification…

Henry Brown
- 2,219
- 8
- 31
- 48
30
votes
8 answers
Swift - Accessing AppDelegate window from viewController
I make walkthrough (onboarding flow) in my app and I'd like to have a skip button.
The button is located on viewController, so I figured out that the best way to move to another viewController would be access app delegate window.
However, it keeps…

theDC
- 6,364
- 10
- 56
- 98