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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:02:14+00:00 2026-05-15T01:02:14+00:00

There is so much info out there on using Apple’s Reachability example, and so

  • 0

There is so much info out there on using Apple’s Reachability example, and so much is conflicting. I’m trying to find out of I’m using it (Reachability 2.0) correctly below.
My App use case is this: If an internet connection is available through any means (wifi, LAN, Edge, 3G, etc.) a UIButton (“See More”) is visible on various views. If no connection, the button is not visible. The “See More” part is NOT critical in any way to the app, it’s just an add-on feature. “See More” could be visible or not anytime during the application lifecycle as connection is established or lost. Here’s how I did it – Is this correct and/or is there a better way?

Any help is Greatly Appreciated!
lq

//  AppDelegate.h

#import "RootViewController.h"

@class Reachability;

@interface AppDelegate : NSObject <UIApplicationDelegate> 
{
    UIWindow *window;
    UINavigationController *navigationController;
    RootViewController *rootViewController;
    Reachability* hostReach;
    // NOT USED: Reachability* internetReach;
    // NOT USED: Reachability* wifiReach;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;

@end


//  AppDelegate.m

#import "AppDelegate.h"
#import "Reachability.h"

#define kHostName @"www.somewebsite.com"

@implementation AppDelegate

@synthesize window;
@synthesize navigationController;
@synthesize rootViewController;

- (void) updateInterfaceWithReachability: (Reachability*) curReach {

    if(curReach == hostReach) {

        NetworkStatus netStatus = [curReach currentReachabilityStatus];
        BOOL connectionRequired = [curReach connectionRequired];

        // Set a Reachability BOOL value flag in rootViewController 
        // to be referenced when opening various views

        if ((netStatus != ReachableViaWiFi) && (netStatus != ReachableViaWWAN)) {
            rootViewController.bConnection = (BOOL *)0;
        } else {
           rootViewController.bConnection = (BOOL *)1;
        }

    } 
}

- (void) reachabilityChanged: (NSNotification* )note {

     Reachability* curReach = [note object];
     NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
     [self updateInterfaceWithReachability: curReach];
}

- (void)applicationDidFinishLaunching:(UIApplication *)application { 

    // NOTE: #DEFINE in Reachability.h: 
     // #define kReachabilityChangedNotification   @"kNetworkReachabilityChangedNotification"

    [[NSNotificationCenter defaultCenter] addObserver: self selector:  @selector(reachabilityChanged:) name: kReachabilityChangedNotification object: nil];

    hostReach = [[Reachability reachabilityWithHostName: kHostName] retain];
    [hostReach startNotifer];
    [self updateInterfaceWithReachability: hostReach];

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

}

- (void)dealloc {
    [navigationController release];
    [rootViewController release];
    [window release];
    [super dealloc];
}

@end
  • 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-15T01:02:14+00:00Added an answer on May 15, 2026 at 1:02 am

    Why not rootViewController.bConnection = (netStatus != NotReachable);, which will still work if they add another type of connectivity?

    (BOOL *) looks like a mistake (it’s equivalent to (signed char *)). In general, I prefer C99’s bool and the C99 specification specifically allows for bool blah:1; if you’re worried about space.

    Also, be careful with the idea that you can check for an “internet connection” — you can check for a network connection, but your ISP could be down, or the host you want to connect to could be down, or someone could’ve drilled through an undersea cable. If kHostName is the hostname you care about connecting to, then it’ll do the right thing.

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

Sidebar

Ask A Question

Stats

  • Questions 403k
  • Answers 404k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here's some code I wrote which seems to do the… May 15, 2026 at 5:20 am
  • Editorial Team
    Editorial Team added an answer If you are on the .NET Framework 3.5, you can… May 15, 2026 at 5:20 am
  • Editorial Team
    Editorial Team added an answer I'd suggest also looking at Christophe Grand's thread safe blocking… May 15, 2026 at 5:20 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.