Understanding iOS App Lifecycle

Asked 1 years ago, Updated 1 years ago, 88 views

On iOS app, I press the home button twice to display the multi-tasking bar, swipe up the app, and exit. Is this equivalent to the Not Running state in iOS app's lifecycle?

With the app I'm making now, starting the app after starting the actual iOS device (this is definitely starting from NotRunning state), and ending it from the multi-tasking bar and starting it again as above are different.

I think it's just a lack of knowledge, but please let me know.

What exactly are the different movements?

→ I try to save the screen I was working on before I finished and restore it when I resume, but when I restart from the exit from the multi-task bar, it doesn't restore and the first screen appears.

If you are using the save/restore app state feature enabled by -application:shouldSaveApplicationState:, etc., then the save state from the multi-tasking bar seems to be destroyed by forced shutdown of the multi-tasking bar:

→ We were doing exactly what you pointed out.
 I understand that it is a specification, thank you.

Considering the question, both end up in Not Running state, but …

User-operated termination is the same as terminating a suspended app:

→ As a result, I am sorry that the question was different from the problem with my application this time.
 I understood one thing as a life cycle knowledge.

ios iphone

2022-09-30 18:54

2 Answers

I can't duplicate the image of the Apple document, so I summarized the running status of the application below.

iOS7 App-Life cycle

  • Launch
    • application:willFinishLaunchingWithOptions/application:didFinishLaunchingWithOptions
  • Move to Foreground
    • applicationDidBecomeActive
  • Move to Background
    • applicationDidEnterBackground
  • Move to Inactive
    • applicationWillResignActive/applicationWillEnterForeground
  • Terminate
    • applicationWillTerminate
      (However, it is not called when it is suspended or when the device is restarted)
  • application:willFinishLaunchingWithOptions/application:didFinishLaunchingWithOptions
  • applicationDidBecomeActive
  • applicationDidEnterBackground
  • applicationWillResignActive/applicationWillEnterForeground
  • applicationWillTerminate
    (However, it is not called when it is suspended or when the device is restarted)

When considering the question, both end up in the Not Running state, but the method called in the state transition at Terminate is different. The following (3.) is considered to be the behavior of the problem.

The presence or absence of notification by applicationWillTerminate depends on whether the application is in Suspended state at exit. If you send an application to the background, applicationDidEnterBackground is likely to be the last time you can finish the application, so you should save the operation screen at that time or at applicationWillResignActive.


2022-09-30 18:54

User-operated termination is the same as terminating a suspended app:

User-initiated termination has the same effect as terminating a suspended app.

App Termination

The next state of Suspended is Not running (Execution States for Apps), so you can think of booting from the multitasking bar as starting from the Not running state.

If you are using the Save/Restore App State feature, which is enabled by -application:shouldSaveApplicationState:, etc., it seems to be a safety specification that the saved state is destroyed by forced termination from the multitasking bar:

Deleting the reserved state information when the app is killed is a safety precaution.

Tips for Saving and Restoring State Information


2022-09-30 18:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.