Async Networking in an iPhone App

Discussion in 'iOS Programming' started by dougr583, Apr 13, 2010.

  1. dougr583 macrumors newbie

    Joined:
    Apr 13, 2010
    #1
    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?
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2

Share This Page