Latest Post

How to use closure button in swift How to use notificationcenter in swiftui with example Longest common subsequence program in swift

 What is life cycle of iOS application?

Ans: Application lifecycle in iOS : the most purpose of entry into iOS apps is UIApplicationDelegate. UIApplicationDelegate could be a protocol that your app must implement to induce notified regarding user events like app launch, app goes into background or foreground, app is terminated, a push notification was opened, etc

viewcontroller lifeCycle of iOS swift

Not running State

Not running State: The app has not been launched or was running but was terminated by the system.

Inactive state

Inactive State: The app is said to be inactive state if it is in foreground but there is no event triggered or there is no user interaction with the app.

The app is going for run the foreground however is presently now no longer receiving events. (It can be executing different code though.) An app commonly remains on this country most effective in short because it transitions to a distinctive country.

The most effective time it remains inactive for any time frame is whilst the person locks the display or the machine activates the person to reply to a few event, along with an incoming call name or SMS message.

 Active state

Active state: The app is said to be active state if it  is running in the foreground and is actively receiving events or user is interacting or api’s are been received. This mode  is basically called normal mode for foreground apps or active Mode.

Background state

Background state: The app is in the background and executing law. Utmost apps enter this state compactly on their way to being suspended. Still, an app that requests redundant prosecution time may remain in this state for a
.
period of time. In addition, an app may be  launched directly at the background enters this state rather of the inactive state. For information about how to execute law while in the background, see “ Background Prosecution and Multitasking.”

Suspended state

Suspended state: The app is said to be suspended state if it is in the kill mode.

The app is in the background but isn’t executing the code. The system moves apps to this state automatically and doesn’t notify them before doing so. While suspended, an app remains in memory but doesn’t execute any action or events. When a low- memory condition occurs, the system may purify suspended apps without notice to make further space for the focus app
 
 

When an iOS app is launched the first thing called is

application: willFinishLaunchingWithOptions:-> Bool. This function is meant for initial application setup. Storyboards have already been loaded at now however state restoration hasn’t occurred however.

Launch

application: didFinishLaunchingWithOptions: -> Bool this function is called next.

This method is also called as callback method this message system is called when the app has finished launching and restored state and can do final initialization similar as creating UI.

applicationWillEnterForeground: is called basically after application: didFinishLaunchingWithOptions: or if your app becomes active again after switching the app or  receiving a phone call or other system interruption.

applicationDidBecomeActive: is called after applicationWillEnterForeground: to finish up the userinteraction to the foreground.

Termination

 W ZnKYQXTdJfPa91gtbwU2BnroeHOTu2eOCWKqGvbWecJ8D ZvgJHEMt3hoNy2yjDs 48ZXPcq49FBugW3299nLRVyhnEXP6z GSa5vjW I

 • applicationWillResignActive: is called when the application  is about to resign from active state or become inactive (for example, when the phone call is received  or the user hits the Home button).

applicationDidEnterBackground: is called when your application enters a background state after becoming inactive. You have approximately 5 seconds to run particular tasks that you need to back things up in case the application been terminated later or right after that.

applicationWillTerminate: is called when the application is about to be removed from memory. Call any final cleanups here.

Both application: willFinishLaunchingWithOptions: and application: didFinishLaunchingWithOptions: can potentially be launched with options identifying that the app was called to handle a push notification or url or something else. You need to return true if your app can handle the given activity or url.

Knowing your app’s lifecycle is important to properly initialize and set up your app and objects. You don’t have to run everything in application: didFinishLaunchingWithOptions, which often becomes a kitchen sink of setups and initializations of some sort.

Leave a Reply

Your email address will not be published.