How to check Internet status in iPhone

Posted by Radix on Stack Overflow See other posts from Stack Overflow or by Radix
Published on 2010-12-27T10:48:30Z Indexed on 2010/12/27 10:53 UTC
Read the original article Hit count: 187

Filed under:
|
|
|

Hello;

I wanted to check whether internet is connected or not using either the SystemConfiguration or the CFNetwork i am not quite sure which one.

Then i want to know that if the internet is connected then is it connected through wifi or not.

I tried an example where i used the below code

-(IBAction) shownetworkStatus
{
    NSURL *url = [NSURL URLWithString:@"www.google.com"];
    if (url!=NULL) {
        lbl.text = @"Connected";
    }
    else {
        lbl.text = @"notConnected";
    }
}

some say that its not valid as per apple and you have to use the SystemConfiguration Framework, Please let me know what needs to be done.

Also i personally think that what i am doing in the above code is not proper as if one day google may also be down due to maintenance or some other factors.

Also if you could provide me a link where i could display the name of the WIFI network then it would be really cool.

I searched the internet then i got these Reachability.h code which again is a bouncer as i wana learn the concepts not copy paste them

Thanks and Regards

Radix

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c