Questions tagged [appdelegate]

In iOS, the app delegate is responsible for managing the app throughout its lifecycle by responding to events such as launch and termination.

2019 questions
21
votes
1 answer

Get Instance Of ViewController From AppDelegate In Swift

I am trying to load a specific ViewController from the app delegate in swift when a user clicks a UILocalNotification. I have figured out that this is called in this function: func application(application: UIApplication!, didReceiveLocalNotification…
PretzelJesus
  • 869
  • 3
  • 11
  • 21
21
votes
2 answers

How to get managedObjectContext for viewController other than getting it from appDelegate?

Recently I came to know that "You really shouldn't be calling down to the AppDelegate to get the managed object context". Apple also has put this recommendation into their documentation here. It goes like this : A view controller typically…
18
votes
1 answer

Why is UIApplicationDelegate method `application(_:configurationForConnecting:options:)` not called reliably

Issue: I find some unexpected behavior regarding the AppDelegate method application(_:configurationForConnecting:options:). The documentation states: UIKit calls this method shortly before creating a new scene. I would expect that this is the case…
de.
  • 7,068
  • 3
  • 40
  • 69
18
votes
2 answers

How to implement push notification for iOS 10[Objective C]?

Can anyone help me with implementing push notification for iOS 10 as i have implemented following code but still getting problem in it: #define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v…
17
votes
7 answers

iPhone registerForRemoteNotificationTypes does not generate an error but does not fire delegate that gives device token

I am developing an iPhone app that needs push notification. I followed the instructions for creating the certifications and modifying the app ID. I am not totally sure I did this correctly, but I did follow the directions. Any idea how I can check…
17
votes
3 answers

'UIApplicationMain' attribute cannot be used in a module that contains top-level code

All of a suden I got this error in my AppDelegate: 'UIApplicationMain' attribute cannot be used in a module that contains top-level code in the line where it says: @UIApplicationMain Now the project cannot build. I am using Swift and Xcode 6.2.…
diegomontoyas
  • 1,785
  • 3
  • 17
  • 22
17
votes
2 answers

Swift: How do I get access to the navigationController in AppDelegate

I have added a NavigationController in the StoryBoard and made it the initial viewController. How do I get access to the NavigationController in the appDelegate. Ctrl-drag from navigationController to AppDelegate does not create an outlet.
RawMean
  • 8,374
  • 6
  • 55
  • 82
16
votes
2 answers

What describes the Application Delegate best? How does it fit into the whole concept?

I think to know what the App Delegate does. It has some nice methods like -applicationDidFinishLaunching which will be called when the app has finished launching, and so on. But what's that actually? Is that some object instantiated in the…
Thanks
  • 40,109
  • 71
  • 208
  • 322
16
votes
2 answers

How to convert from UIKit life cycle to SwiftUI life cycle in iOS 14 (Xcode 12 Beta)

I am currently working on SwiftUI app in which I am using SceneDelegate and AppDelegate. I would like to know how I can convert the life cycle from UIKit to SwiftUI one where there is an App struct and with scenes etc. Also I would like to know how…
Osama Naeem
  • 1,830
  • 5
  • 16
  • 34
16
votes
2 answers

Why I am getting Lazy loading NSBundle MobileCoreServices.framework?

When I redirect from main viewController to another viewController I'm getting this Error: Lazy loading NSBundle MobileCoreServices.framework, Loaded MobileCoreServices.framework, System group container for…
Naresh
  • 16,698
  • 6
  • 112
  • 113
15
votes
1 answer

How is the return value of application:openURL:options: used?

Reading the documentation for UIApplicationDelegate - application:openURL:options Return: YES if the delegate successfully handled the request or NO if the attempt to open the URL resource failed. What does returning YES vs NO impact? Is it just…
Ben Flynn
  • 18,524
  • 20
  • 97
  • 142
15
votes
3 answers

Why is AppDelegate.swift window an optional?

I was reading Apple docs, when I found this sentence: The AppDelegate class contains a single property: window. var window: UIWindow? This property stores a reference to the app’s window. This window represents the root of your app’s view…
user5273262
15
votes
2 answers

Swift Passing data from appDelegate to another class

I need to pass a variable from the AppDelegate to another class that I have created to hold global variables of the project and I'm not able to find a way to make it work. This is the code in the AppDelegate: func application(application:…
MeV
  • 3,761
  • 11
  • 45
  • 78
14
votes
0 answers

isProtectedDataAvailable is returning true always in iOS

Problem isProtectedDataAvailable is true but applicationProtectedDataDidBecomeAvailable is getting called after 10~20 seconds in iOS which means isProtectedDataAvailable was supposed to be false before that callback is called. I am working on iOS…
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
14
votes
2 answers

UIWindow not filling screen for new devices?

I'm working with an old Xcode project which is roughly 7/8 years old and I've migrated it to Objective-C 2.0 and to support ARC. The project didn't support Auto-Layout (this was just before it was released) prior to me working on it. I've managed to…
Luke97
  • 529
  • 3
  • 11
  • 27