views:

213

answers:

1

In an iphone application that I am building, I am parsing XML in a number of view controllers when they are loaded by a user.

Every time I do this, I am doing the following:

  • establishing an NSURLConnection (in viewDidLoad)
  • storing the data retrieved and error handling (connection delegate methods)
  • creating an NSXMLParser
  • parsing the XML (NSXMLParser delegate methods)

I'm curious to know what your approach to this problem would be?

I myself intend writing a simple subclass of id with a few object methods and all the NSURLConnection and NSXMLParser delegate methods contained in it -- so that responsibility is with this subclass and can simply be instantiated in a viewcontroller. Is this viable, or should the delegate be my view controller?

Thank you

A: 

you can make subclass as delegate. your sub class should be done something like take basic information to execute the NSURLConnection and parse the out put and return the output back to controller.

Ex: if you want to list of image from picasa ... then send request input to your subclass then return list of images to viewcontroller.

Girish Kolari
Thank you for this -- I think I have to decide whether to write all this functionality into one class or rather separate into 2 classes (one for establishing an NSURLConnection, another for parsing the XML).
ddawber