简体   繁体   中英

iPhone help on using XMLParser and UI while waiting for results

can someone provide a little guidance on the best way to handle iPhone UI and processing while parsing a SOAP message? Here is the context:

  • I have an app that allows a user to select a car (from a list of cars) they are interested in viewing.
  • When they pick a car, I push a carDetails viewcontroller that shows the car detail categories. When I initialize carDetails, I alloc/execute another class called getCarData that contains SOAP and XMLParser methods that retrieve and load all the car details from a web service.
  • Currently, the getCarData class returns control back to carDetails before it has completed it's processing (I believe due to the asynchronous nature of the XMLParser)
  • But I need data from getCarData to be loaded before I allow the user to select any drill-down category information in carDetails (ie Interior, Engine, etc.)

My questions are;

  • What is the best way to handle the wait process until the data is loaded?
  • I have seen some forum questions on firing off separate threads so I don't tie up the UI, but I actually do want the user to wait (if necessary) until the data is loaded. So should I create another thread? Should I just simply display a progress window that hides the main window until data is loaded?
  • What is the best way to check and see if the data has finished loading and if not, display the activity/progress view? In other words, should I handle it in the carDetails, getCarData, or maybe the AppDelegate?

Sorry for the multiple questions and (probably) noob problems, but I can't seem to find many discussions or code examples that I can use.

Thanks in advance - Mike

The typical protocol used by Apple in this situation is to define a method to be called when the processing/loading is done. The method could be called something like this:

-(void)carDetailsDidFinishLoading

You can wait for this method to be called before allowing the user to select things in your interface. Keep everything disabled until this fires.

Since you're essentially freezing your interface, you will probably want to display a loading symbol, UIActivityIndicator, to let the user know your app hasn't just frozen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM