views:

71

answers:

1

Hi

The scenario is as follows:

My application has a tabBarController on tapping a tab there occurs some parsing of XML from server which takes some time.The data recovered from parsing is gonna be there on the view of the selected viewController(i.e; the data is used in the viewDidLoad method).Now how can I ensure that the viewDidLoad method is called only when the parsing has been completed. Parsing is done in some delegate methods of the NSURLConnection class which gets called after some time the connection has established.In the meantime the viewDidLoad method gets called.

+3  A: 

why don't you move your code from viewDidLoad into a custom function and then call that when your XML has been parsed?

for instance I have some applications where blog feeds/rss/xml are loaded into a UITableViewController and on connectionDidFinish: I just call [tableView reloadData]; rather than trying to run viewDidLoad again.

Thomas Clayson
Or use NSNotificationCenter
willcodejavaforfood
Thanks Thomas that worked for me
bhatti
How can I use NSNotificationCenter to delay viewDidLoad???
bhatti
Suppose I posted the notification when parsing is completed.But how will I delay the viewDidLoad??
bhatti
you can't and shouldn't delay it. thats the whole point - if you want to delay some code then you need to put it into its own function and delay it. The whole point is it is called AS soon as the view loads.
Thomas Clayson