Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 01-26-2010, 01:40 PM   #23 (permalink)
KennyChong
iPhone SDK fanatics!
 
Join Date: Aug 2009
Location: Malaysia
Posts: 370
Default

Quote:
Originally Posted by rhuettl View Post
Hi there,

is there a simple piece of code testing if the internet is available on the iPhone - i know the reachability example app but that seems to be a great overhead. So i only like a network test (CFNetwork ?) who can check this - any help available?

Cheers :-)
Ralf

Two methods I tried. Reachability is still the best for me. It detect even changes from WifI to 3G to EDGE, etc...

Easier to use method is the UIWebView protocol itself. Hope the code below helps.

#pragma mark UIWebView delegate methods

- (void)webViewDidStartLoadUIWebView *)webView
{
// starting the load, show the activity indicator in the status bar
[myActivityIndicatorView startAnimating];
}

- (void)webViewDidFinishLoadUIWebView *)webView
{
[myActivityIndicatorView stopAnimating];
}

- (void)webViewUIWebView *)webView didFailLoadWithErrorNSError *)error
{
int myErrorCode;

[myActivityIndicatorView stopAnimating];

myErrorCode = [error code]; // myErrorCode = -999 if user cancel action, not network problem
if (ckErrorCode != -999)
{
// Your error handling code here
NSLog(@"UIWebView Load Failed-Error");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error!" message:@"Unable to connect to the website." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
}
}

// #pragma mark UIWebView delegate methods
__________________
KennyChong
iPhone SDK Fanatic!
KennyChong is offline   Reply With Quote
 

» Advertisements
» Online Users: 348
13 members and 335 guests
ADY, antonwilliams, dcool, Desert Diva, HemiMG, jakerocheleau, leahov, michelle, MozyMac, nobre84, smithdale87, thh022, vogueestylee
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,721
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:21 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.