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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:41:28+00:00 2026-05-25T12:41:28+00:00

I have this line of code: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stop) name:UIApplicationDidEnterBackgroundNotification object:nil]; Works fine

  • 0

I have this line of code:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stop) name:UIApplicationDidEnterBackgroundNotification object:nil];

Works fine in iPhone 4.3 simulator and on my iPhone running 4.x. However a crash occurs there on an iPhone running 3.x. Makes sense. My guess is that that line of code doesn’t work when there is no multitasking.

It’s difficult for me to debug because the person testing for me with the 3.x system is in a remote location. I’m not even sure whether the symbol UIApplicationDidEnterBackgroundNotification evaluates to the correct string, or nil, or random uninitialized memory, or what on that OS.

But beyond figuring out why it’s failing, which I can do with some effort, what am I supposed to do? How do I detect whether a particular notification exists before I observe it? Or do I check if multitasking is available as a general category? I guess I thought the line of code would be safe. If the OS never generates that notification, then I don’t get notified, but the line shouldn’t crash.

  • 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-25T12:41:29+00:00Added an answer on May 25, 2026 at 12:41 pm

    You should check whether the iOS version is 4.0 or later when compiling (there are inbuilt preprocessor #defines for this) and test multitasking support as well (in case it’s disabled on the device when it would otherwise be supported):

    #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0
        if([[UIDevice currentDevice]
            respondsToSelector:@selector(isMultitaskingSupported)] &&
           [[UIDevice currentDevice] isMultitaskingSupported])
        {
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stop) name:UIApplicationDidEnterBackgroundNotification object:nil];
        }
    #endif
    

    You don’t have to use the #if, but it saves compiling in extra checks which you know will always return false.

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

Sidebar

Related Questions

Countless GameCenter tutorials do this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(localUserAuthenticationChanged) name:GKPlayerAuthenticationDidChangeNotificationName object:nil]; I have other
I have this line of code in an assembly: HttpContext.Current.Server.MapPath This works great if
I have this line of code: <a href=# id=profilelink name=profilelink value=<?php echo $id./.$block_record;?> onClick=return
i have this line of code : document.getElementById(object).innerHTML=data; where object is equal to 'index'
I have this line of code that returns index of particular object in a
I have this line of code. It works just fine, but I'm wondering if
I have this line of code: <a href=# id=profilelink name=link2 onClick=viewornot(<?php echo $freechat_id ?>)><?php
I have this line of code in java: new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name, append), UTF-8));
I have this line of code Account.build_address and this works but I need to
I have this line of code for page load: if ($(input).is(':checked')) { and it

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.