Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dougr583

macrumors newbie
Original poster
Apr 13, 2010
1
0
I'm new to iPhone programming, trying to design an app that makes occasional web service calls for data and am struggling with the environment. I'm trying to design a set of classes that handle the data retrieval in a way that doesn't require a busy-waiting loop. If I was doing this in java or c++, I'd be using callbacks or a separate thread + shared memory, but I can't come up with a clean way to do it in Objective C on the iPhone. I've bought a bunch of books, but all the examples are so simple that they aren't helping me much.

Can anyone point me to a good resource for a non-trivial async networking example? And/or explain to me how to wait for a network request to finish without using a busy-waiting loop or a timer loop in the main thread?

Basically, what I want to do is have a view with a set of controls that will display data returned from a network request, initiated by the user touching a button. I want to set an indicator showing the user that the data is being fetched, fire the request off in the background without tying up the main thread so that the user can touch the "Cancel" button if they change their mind. Should be simple, right?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.