I need to know if the device is connected via WIFI or not. This should be pretty simple, but I broke my neck on the sample code apple supply HERE. I can't seem to get it to work in my own app. Is this not the only thing I need to do?
IN H:
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
@class Reachability;
@interface FirstViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
Reachability* wifiReach;
}
IN M: I just try to call the following code in viewDidLoad:
wifiReach = [[Reachability reachabilityForLocalWiFi] retain];
But compiling results in:
WARNING: no '+reachabilityForLocalWiFi' method found
ERROR: "_OBJC_CLASS_$_Reachability", referenced from: objc-class-ref-to-Reachability in FirstViewController.o - Symbol not found
Seeing this, I'm probably doing something really wrong here. Thought this would be a simple task. Damn my good ideas.
#import "Reachability.h"
and
- (BOOL)networkCheck{
Reachability *curReach = [[Reachability reachabilityForInternetConnection] retain];
NetworkStatus netStatus = [curReach currentReachabilityStatus];
[curReach release];
switch (netStatus)
{
case NotReachable:
{
NSLog(@"NETWORKCHECK: Not Connected");
return false;
break;
}
case ReachableViaWWAN:
{
NSLog(@"NETWORKCHECK: Connected Via WWAN");
return false;
break;
}
case ReachableViaWiFi:
{
NSLog(@"NETWORKCHECK: Connected Via WiFi");
return true;
break;
}
}
return false;
}
then [self networkCheck]
will return true if connected to wifi. I use the reachability code too, and this works perfectly in all my applications.