Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6164613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:01:29+00:00 2026-05-23T22:01:29+00:00

How to know the termination of app? I added this code in viewDidLoad [[NSNotificationCenter

  • 0

How to know the termination of app?

I added this code in viewDidLoad

[[NSNotificationCenter defaultCenter] addObserver:self  
selector:@selector(applicationWillTerminate:) name:UIApplicationWillTerminateNotification 
object : nil];

and if the app ends, it will notify me of termination.

- (void)applicationWillTerminate:(NSNotification*) notif{
    NSLog(@"program will end");
}   

But it doesn’t work…
I terminated the app, by clicking home button and pressing home button in 2sec, followed by clicking app icon’s ‘-‘button.

I want to be notified of the termination of app.
And also intereseted in what function to be called when the app terminates.(is it viewDidLoad?)
And the termination of app by clicking the ‘-‘button is to send the app SIGKILL?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:01:30+00:00Added an answer on May 23, 2026 at 10:01 pm

    I terminated the app, by clicking home button and pressing home button in 2sec, followed by clicking app icon’s ‘-‘button.

    If you press the home button, your app will be sent to the background. When you then kill it (by pressing the - button), it likely does not get the notification because it is not running anymore.

    applicationWillTerminate is called on iOS < 4.0, when no multitasking (background) is available or when UIApplicationExitsOnSuspend is set in the info.plist file.

    On iOS 4.x, when your app is sent to the background, it receives applicationWillEnterForeground:. Look at the UIApplicationDelegate Protocol Reference for more info:

    You should use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

    Keep in mind that you need to do this both in applicationWillEnterForeground and applicationWillTerminate if you also support iOS < 4

    Have a look also at this post from S.O.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know what wrong with this code but everytime when I run the
I'm enabling Automatic Termination in my app. I added the NSSupportsAutomaticTermination key to my
Anyone know why I am getting this error? Terminating app due to uncaught exception
I have a code that kill's my app with this exception Terminating app due
Know of any good libraries for this? I did some searches and didn't come
Know this might be rather basic, but I been trying to figure out how
I know this might be a no-brainer, but please read on. I also know
i am getting exception over these lines of code dont know why its giving
I had not run into this before but I wanted to know if it's
There are LOTS of iphone-related questions of this type. I know; I read them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.