1

Ok, so in my AppDelegate, I initialise various stuff in didFinishLaunchingWithOptions, however I create my views in applicationDidBecomeActive.

My reasoning behind this was that when the app is executing stuff in the background (push notifications), the didFinishLaunching... will be called so I don't want to create UI stuff there, if the application will not be visible.

This has worked for me, however now with quick actions, say i want to have a quick action that goes to one of my tabs. I can't do it in didFinishLaunchingWithOptions, since the views won't be created until didBecomeActive.

So, my questions are:

  1. Have I misunderstood something regarding the lifecycle and timing of UI and didFinishLaunching.../didBecomeActive? That is, is it good practice to do what i do, create the views to be used in didBecomeActive and not didFinishLaunching...?

  2. I haven't really found any good examples regarding this. I suppose i could store away the UIApplicationShortcutItem in didFinishLaunching... and then use it in didBecomeActive. It seems a bit 'hacky', but i haven't figured out anything else.

Pointers much appreciated.

Hamish
  • 78,605
  • 19
  • 187
  • 280
Mathias
  • 3,879
  • 5
  • 36
  • 48
  • Hi guys, huge thanks for replying. @originaluser2 i hear you but its not like that. I only init them once. I basically check if i need to switch view every time after that, due to how the app works. Question: what happens if app is launched in "background" fetch, and then is launched for user view? Will didfinishlaunching get called again? – Mathias Jan 25 '16 at 22:40
  • Exactly. And then i don't see how i would want to create my ui code there only if not running in background mode. If i skip the UI creation due to it being launched in background, but the same process later is used to start it proper, it will fail since i skipped creating the ui before? – Mathias Jan 25 '16 at 22:47
  • @Cristik oops, I guess I was thinking about the push notification launch key... weird there isn't one for background fetches... – Hamish Jan 25 '16 at 23:06
  • Right. Then i just need to act on my UIApplicationShortcutItem in the end of didBecomeActive... i suppose i'll have to do what i outlined in #2 above and store it in a property in didfinishlaunching... and use it in didbecome active. – Mathias Jan 25 '16 at 23:07

0 Answers0