siva
siva

Reputation: 1412

How to find whether iphone device connected to 3G /Wifi using Reachability

Can any one get me idea to find whether iphone device connected to 3G /Wifi using Reachability.kindly get me some samples / URL's .im new in this iphone development.

Thanks in advance

Upvotes: 0

Views: 794

Answers (2)

user5938635
user5938635

Reputation:

firstly add SystemConfiguration.framework to your project

//Class.h
#import "Reachability.h"
#import <SystemConfiguration/SystemConfiguration.h>

- (BOOL)connected;

//Class.m

- (BOOL)connected
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    NetworkStatus networkStatus = [reachability currentReachabilityStatus];
    return networkStatus != NotReachable;
}
Then, I use this whenever I want to see if I have a connection:

if (![self connected]) {
    // Not connected
} else {
    // Connected. Do some Internet stuff
}

Upvotes: 0

KingofBliss
KingofBliss

Reputation: 15115

You could try to start from the Rechability example from Apple http://developer.apple.com/iphone/library/samplecode/Reachability/

Upvotes: 1

Related Questions