0

First of all I'd like to say sorry in case you consider my question dummy, but I'm really new to iOS and just want to understand how things works. My question is - what happens with the code execution when I press the home button on my iOS device. Imagine such a situation I have a couple of tasks running - UI is updating on the main thread, background thread downloads some stuff from the web and at some point(while those tasks are not finished). So what will happen with the code execution ? Will it just suspend, e.g. execution will just stop on some line of the code and will continue once the app will be brought back to background? Or something else will happen ? Is it safe to assume that if I'll send the app to background and then awake it back the code will be executed in the same way/order and the app will behave the same way as it will without sending the app to background(assuming that I'm not doing anything specific when app enters background) ? I tried to find something in Apple docs, but there is not such a detail explanation of what will happen. Thank you for your help

starwarrior8809
  • 361
  • 1
  • 10

1 Answers1

1

Refer to this: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1622997-applicationdidenterbackground

When an app goes into background OS freezes the memory allocated to your app, It means no code of yours will get called after appdelegate calls didEnterBackground method.

However, there are several background modes available in ios which we can turn on using capabilities section. When we have such capabilities turned on, our app can still interact with those services while in BG mode. For example we can turn Audio capability in background mode and let our audio player in the app runenter image description here

PK-V
  • 194
  • 1
  • 9