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

  • Home
  • SEARCH
  • 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 7444583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:32:38+00:00 2026-05-29T11:32:38+00:00

I’m using the Apple provided sample code to monitor Reachability – but it’s still

  • 0

I’m using the Apple provided sample code to monitor Reachability – but it’s still causing me a headache. I’m running on iOS 5, btw.

// Initialise

hostReach = [[Reachability reachabilityForInternetConnection] retain];

[hostReach startNotifier];

and,

-(void) updateConnectionStatus
{
    // Check Internet connectivity

    NetworkStatus netStatus = [hostReach currentReachabilityStatus];

    if(netStatus == NotReachable)
    {
        NSLog (@"updateConnectionStatus: network not reachable!");

       [self setNetworkAvailable:NO];
    }
    else
    {
        NSLog (@"updateConnectionStatus: network reachable!");

       [self setNetworkAvailable:YES];
    }
}

and also,

//Called by Reachability whenever status changes.
- (void) reachabilityChanged: (NSNotification *) note
{
NSLog (@"reachabilityChanged");

   [self updateConnectionStatus];
}

not forgetting,

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    NSLog (@"applicationWillEnterForeground");

    [self updateConnectionStatus];
}

I’ve been using this a while, but am wanting to handle reachability in a non-trivial way within the app, for instance using cached data when the network isn’t available.

The first problem is that the notification for a change of status does not arrive until around 10th of a second after an app has entered the foreground, and even a manual check when the app re-enters the foreground (as shown above) returns in incorrect result. See this example log from the console,

2012-02-01 13:31:02.566 myapp[9807:707] applicationWillEnterForeground
2012-02-01 13:31:02.632 myapp[9807:707] Reachability Flag Status: -- ------- networkStatusForFlags
2012-02-01 13:31:02.634 myapp[9807:707] updateConnectionStatus: network not reachable!
2012-02-01 13:31:02.660 myapp[9807:707] reachabilityChanged
2012-02-01 13:31:02.662 myapp[9807:707] Reachability Flag Status: WR t----l- networkStatusForFlags
2012-02-01 13:31:02.663 myapp[9807:707] updateConnectionStatus: network reachable!

I have tried both,

hostReach = [[Reachability reachabilityWithHostName:@"www.apple.com"] retain];

and,

hostReach = [[Reachability reachabilityForInternetConnection] retain];

This means that if the network was unreachable when the app last run, the recovery is less efficient that it might be once the app runs again with a network connection.

Is this delay unavoidable?

My other issue is that my app apparently sometimes does not receive these notifications. This seems to happen when my app has been in the background for a while – though I can’t recreate this at will.

But sometimes when I come back to the app, the last notification it received was that the network was unreachable, and it apparently never sees a network reachable notification 🙁

Anyone else seen anything like that?

Thanks.

  • 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-29T11:32:39+00:00Added an answer on May 29, 2026 at 11:32 am

    To answer my own question, calling updateConnectionStatus on a separate thread seems to have fixed the problem (it seems to more reliably return the correct status), though to be honest, I’m not sure why.

    The delayed notifications remains a nuisance.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

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.