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 11-18-2009, 05:31 AM   #19 (permalink)
redon
Hot Cocoa Touch
 
redon's Avatar
 
Join Date: Oct 2009
Location: Florida
Posts: 193
Default

Quote:
Originally Posted by wynodir View Post
If the code in any case connects to a web server to try if there's a connection, why not just do this:

Code:
- (BOOL) connectedToNetwork
{
   return ([NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.myserver.com/smalltext.txt"]]!=NULL)?YES:NO;
}
This function will return NO if it cannot reach the file. Otherwise, it will return YES. I tried it in flight mode and in 3G mode. It works.
i tryed the following code, put my iphone in airplane mode and ran the app. it appears to not work...at all


Code:
- (BOOL) connectedToNetwork {
	return ([NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.apple.com/"]]!=NULL)?YES:NO;
	
	if (YES) {
	}
	
	if (NO) {
		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"no internet connection" 
													   delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[alert show];
	    [alert release];
	}
}
__________________
http://www.bugspray.me/
Search GetFit! on the App Store.
redon is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,877
Threads: 89,222
Posts: 380,720
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:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.