Question : Timing in objective-c for iphone - How do I wait until data returned from URL without freezing the User Interface?

in an iPhone app I have a method in which I request some data from a URL, and then display this data.

If I loop until the data != nil, then this freezes my UI until the URLs have returned, right?
Do I need to do some multithreading to free the UI up while my URLs load?
In C# I would use a simple BackgroundWorker.  Should I be using something similar in objective-C?
How can I do this better?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
	int i = 0;
	while (i != 1) {
		if (myData1 != nil && myData2 != nil && myData3 != nil && myData4 != nil && myData5 != nil && myData6 != nil) {
			//can you add a nil object to an array
			[myMA addObject:myData1];
			[myMA addObject:myData2];
			[myMA addObject:myData3];
			[myMA addObject:myData4];
			[myMA addObject:myData5];
			[myMA addObject:myData6];
			i = 1;
		}
	}



Answer : Timing in objective-c for iphone - How do I wait until data returned from URL without freezing the User Interface?

You can use threads in Objective-C too. You will see the background job in the following tutorial:
Threading tutorial using NSthread in iPhone SDK (Objective-C)
http://www.xprogress.com/post-36-threading-tutorial-using-nsthread-in-iphone-sdk-objective-c/

Or this article:
Programming threaded processes in iPhone      
http://www.eigo.co.uk/Programming-threaded-processes-in-iPhone.aspx

In iOS Reference Library you can find "Threading Programming Guide": http://developer.apple.com/iphone/library/documentation/cocoa/conceptual/Multithreading/CreatingThreads/CreatingThreads.html
Random Solutions  
 
programming4us programming4us