Doing some downloading without blocking you app
Posted
by
Code
on Stack Overflow
See other posts from Stack Overflow
or by Code
Published on 2010-12-26T19:56:54Z
Indexed on
2010/12/27
5:54 UTC
Read the original article
Hit count: 200
iphone
|objective-c
Hi guys,
I'm working on my first app that's doing a few different web connections at once.
My first screen is my Menu.
And at the bottom of viewDidLoad of MenuViewController i call a method that gets and parses a .xml file that is located on my webserver.
Also at the bottom of viewDidLoad i do
FootballScores = [[FootBallScores alloc] init];
and FootballScores makes a connection to a html page which it loads into a string and then parses out data.
Now since both of these are getting called at the bottom of viewDidLoad of the class thats is responsible for the main menu(first screen in the app) it means the app is kinda slow to load.
What is the right way to do the above? Should i remove the 2 pieces of code from my viewDidLoad and replace with maybe
dataGetterOne = [NSTimer scheduledTimerWithTimeInterval:1.000 target:self
selector:@selector(xmlParser) userInfo:nil repeats:NO];
dataGetterTwo = [NSTimer scheduledTimerWithTimeInterval:2.000 target:self
selector:@selector(htmlParser) userInfo:nil repeats:NO];
This would mean that the methods get called later on and the viewDidLoad gets to finish before the i try get the data from the web servers.
Making 2 connections to we bservers a second apart to quick? Can the iphone handle having 2 connections open at once?
I'm really unsure of anything bad/dangerous I am doing in regards to connections.
Many Thanks -Code
© Stack Overflow or respective owner