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 12-15-2009, 10:44 AM   #21 (permalink)
ziophase
Registered Member
 
Join Date: Aug 2009
Posts: 58
Default

I like the idea of loading a small string from the web. I tested it on the simulator and the following code works fine if my internet is connected or not connected. I gave it a 2 second timeout...

Code:
-(void)viewDidAppear:(BOOL)animated {
	NSString *connected = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.mysite.com/smallfile.php"]];
	wait(20000);
	if (connected == NULL) {
		NSLog(@"Not connected");
	} else {
		NSLog(@"Connected - %@",connected);
	}
}
EDIT: Tested it on the device as part of a much bigger app. Works as expected in flight mode / normal connection. If you want to increase the timeout perhaps it might be worth it, but it's working fine for me!

Last edited by ziophase; 12-15-2009 at 11:06 AM. Reason: more info available
ziophase is offline   Reply With Quote
 

» Advertisements
» Online Users: 297
16 members and 281 guests
ADY, antonwilliams, dacapo, dcool, HemiMG, iosdevjtp, jakerocheleau, leahov, MarkC, masc2279, morands, MozyMac, sly24, 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,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:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.