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 6081543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:11:15+00:00 2026-05-23T11:11:15+00:00

In iOS4 I’m registering the following notification: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillTerminate:) name:UIApplicationWillTerminateNotification object:[UIApplication sharedApplication]];

  • 0

In iOS4 I’m registering the following notification:

[[NSNotificationCenter defaultCenter]   addObserver:self
                                                 selector:@selector(appWillTerminate:)
                                                 name:UIApplicationWillTerminateNotification
                                                 object:[UIApplication sharedApplication]];

-(void)appWillTerminate:(UIApplication *) app {
    NSLog(@"terminate");
}

I know that this is not called in all the situations like in the prev iOS versions, however, simply by registering this I get a EXC_BAD_ACCESSS when the app exits. Still, I can’t remove it because my app supports iOS3.0+. How can I handle this?

UPDATE: Here is the crash log:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000011
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                 0x0000441c objc_msgSend + 20
1   Foundation                      0x00015432 _nsnote_callback + 150
2   CoreFoundation                  0x000271da __CFXNotificationPost_old + 390
3   CoreFoundation                  0x00026e7a _CFXNotificationPostNotification + 122
4   Foundation                      0x00004720 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
5   Foundation                      0x0000de3a -[NSNotificationCenter postNotificationName:object:] + 14
6   UIKit                           0x000bef10 -[UIApplication _terminateWithStatus:] + 164
7   UIKit                           0x000be1b0 -[UIApplication _handleApplicationSuspend:eventInfo:] + 1980
8   UIKit                           0x0007e4a0 -[UIApplication handleEvent:withNewEvent:] + 3620
9   UIKit                           0x0007d470 -[UIApplication sendEvent:] + 60
10  UIKit                           0x0007ccf8 _UIApplicationHandleEvent + 6804
11  GraphicsServices                0x00005dd8 PurpleEventCallback + 1024
12  CoreFoundation                  0x00035e40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 22
13  CoreFoundation                  0x00035dfe __CFRunLoopDoSource1 + 158
14  CoreFoundation                  0x0002809e __CFRunLoopRun + 574
15  CoreFoundation                  0x00027d74 CFRunLoopRunSpecific + 220
16  CoreFoundation                  0x00027c82 CFRunLoopRunInMode + 54
17  GraphicsServices                0x00004e84 GSEventRunModal + 188
18  UIKit                           0x00004f8c -[UIApplication _run] + 564
19  UIKit                           0x000024cc UIApplicationMain + 964
  • 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-23T11:11:16+00:00Added an answer on May 23, 2026 at 11:11 am

    Make sure that you remove the observer in any class that is listening for the terminate notification. If you are not removing the notification it will try to post it to a deallocated object and then your application will crash. You should not be crashing for listening to a notification that does not exist, it just would not get called.

    //YourClass
    -(id)init
    {
        if((self = [super init]))
        {
            [[NSNotificationCenter defaultCenter]   addObserver:self
                                                 selector:@selector(appWillTerminate:)
                                                 name:UIApplicationWillResignActiveNotification
                                                 object:[UIApplication sharedApplication]];
        }
        return self;
    }
    
    -(void)appWillTerminate:(NSNotification *)note {
        NSLog(@"terminate");
    }
    
    -(void)dealloc
    {
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    
        //Other releases
        [super dealloc];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In iOS4 I used the following import statement #import <QuartzCore/QuartzCore.h> Now in iOS5 in
In iOS4 (4.3 simulator) when I use the font Myriad Pro with the following
I get the following error when testing on iOS4: dyld: Symbol not found: _OBJC_CLASS_$_NSJSONSerialization
The following code works as expected on iOS4.3 iPhone and iPad, and iOS5 iPhone,
I have some UIViewControllers from my old iOS4 project, they are using .xib, created
I'm guessing this must be new functionality as this code fail on my iOS4
I can get individual uncompressed frames from the iPhone's camera in iOS4. What i
I'm working on an iOS project that has to work from iOS4. I have
Before iOS4.0 clicking the home button on iPhone exits the application, and Apple had
Is iOS4.0 compatibility required for all app-store submissions now? To my understanding, your application

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.