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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:49:44+00:00 2026-06-07T03:49:44+00:00

In my iOS project, I would like to display a message to the user

  • 0

In my iOS project, I would like to display a message to the user to connect to the internet before certain network operations, so I wrote the following check using Apple’s Reachability class:

Reachability *reach = [Reachability reachabilityWithHostName:@"google.com"];
if([reach currentReachabilityStatus] == NotReachable) {
    // ...prompt user to establish an internet connection
} else {
    // ...send an asynchronous request with a timeout
}

However, this had one very big problem–when the device was on a very lossy network (for example, when uplink packet loss is set to 100% on OS X Lion’s Network Link Conditioner), [Reachability reachabilityWithHostName:@"google.com"] would block the main thread for 30 seconds before determining a connection was not available. The following code, however, does not block:

if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) {
    // ...prompt user to establish an internet connection
} else {
    // ...send an asynchronous request with a timeout
}

Looking at the implementation of Reachability shows that both of these methods use SystemConfiguration.framework, but the first method uses SCNetworkReachabilityCreateWithName while the second uses SCNetworkReachabilityCreateWithAddress. Why does the first method block, while the second does not? Is the second method a good way to check for connectivity? Or is there a better way?

  • 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-06-07T03:49:45+00:00Added an answer on June 7, 2026 at 3:49 am

    The first one tests whether it can reach google.com, while the second one simply checks whether there’s any internet connection possible (which it thinks there is, even though there’s packet loss).

    Basically just put it in a thread or in a background queue. The only way to reliably know whether you have a good connection is to test it, and any test is going to be blocking or asynchronous. You simply can’t have it instantly available, ever.

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

Sidebar

Related Questions

I have a Titanium Mobile project for iOS devices and would like to make
I'm using ASIHTTPRequest in my iOS project. i would like to see all the
I have some C code in an iOS project that I would like to
I have downloaded an iOS project and would like to know how to import
I am using FBConnect in my iOS project to authorize the user (SSO). Once
I've downloaded the iOS CloudApp API files from the CloudApp website. I would like
I would like to know if there's an iOS library or framework for loading
I work on a webapp project with HTML5 / CSS. I would like to
I have an Universal iOS Project and in this project I have to display
I would like to be able to get the current version of my iOS

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.