Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 04-11-2008, 10:02 PM   #2 (permalink)
CoffeeKid
Guest
 
Posts: n/a
Default Re: Pulling Data From A Web Page

I figured it out. For anyone that also needs to do this, its simplier then it looks.

Here's the Code:
Code:
	NSString *urlStr = [NSString stringWithFormat:@"%@/index.php?some_name=%@", url, name];
	NSURL *theURL = [[NSURL alloc] initWithString:urlStr];
	
        //get the data from the web page
	NSString * results = [NSString stringWithContentsOfURL:theURL];
	
        //Seperate the data by a | delimiter
	NSArray * chunks = [results componentsSeparatedByString:@"|"];
	
        //put the data into some class variables
	NSScanner * scanner = [[NSScanner alloc] initWithString:[chunks objectAtIndex:0]];
	[scanner scanFloat:&load];
	scanner = [[NSScanner alloc] initWithString:[chunks objectAtIndex:3]];
	[scanner scanInt:&diskUsage];
	users = [[NSString alloc] initWithString:[chunks objectAtIndex:4]];
Hope this helps someone, because this took me HOURS to figure out!

-CoffeeKid
  Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 262
15 members and 247 guests
cordoprod, FANFAN, giraffe81, harrytheshark, iruirc, Jompe71, kiancheong, learnSomething, nico.overbeeke, nlc, Rainer, Rossco, Saurman, sheonlee, sourman
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,282
Threads: 39,074
Posts: 171,341
Top Poster: smasher (2,575)
Welcome to our newest member, FANFAN
Powered by vBadvanced CMPS v3.1.0

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