views:

50

answers:

1

hi,

i encounter an issue with my application.

On one hand when my app launches, the first view displayed is a tableview within a tableviewcontroller.

On the other hand my app calls a web service to collect data. These methods are in MyAppDelegate\applicationDidFinishLaunching.

The thing is that my tableview is made of custom cells that need data from the web service.

I noticed that the view (with the tableview) is launched first and then MyAppDelegate\applicationDidFinishLaunchin is executed.

As a result the labels of my custom cells are all equal to null as my arrays aren't filled yet by the web service.

I would like to know the proper way to make it.

If anyone has an idea please tell me.

Wallou

A: 

Use NSNotificationCenter to communicate to your UITableViewController that it needs to reloadData for the table.

To Register (in your UITableViewController.viewDidLoad):

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(dataLoaded:)
    name:@"myapp.dataloaded" object:nil];

- (void)dataLoaded:(NSNotification *)notification
{
    [self.table reloadData];
}

To post notifications (after you loaded the data):

[[NSNotificationCenter defaultCenter]
    postNotificationName:@"myapp.dataloaded" object:nil];
willcodejavaforfood
thx for the reply.its my first iphone app.I've read over the NSNOtificationCenter many times but never had to use it.Can you help me a bit in implementing it in my code ?? I'm a bit lost (i.e where to do what?)thx again
wallou
OK - hold on a sec :)
willcodejavaforfood
Updated my answer with code that might work :)
willcodejavaforfood
thx for the fast answers.it s what i was looking for.bye
wallou
No problems mate :)
willcodejavaforfood