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 04-11-2008, 11: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
 

» Advertisements
» Stats
Members: 158,557
Threads: 89,126
Posts: 380,253
Top Poster: BrianSlick (7,103)
Welcome to our newest member, wTaylorDaviesp
Powered by vBadvanced CMPS v3.1.0

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