-1

I've created a split view project in Xcode and I'm using an NSXMLParser to retrieve data from and XML file on the Internet. The data comes in fine and assumes the correct structure, but when I test it out, I found that UITableViewDelegate methods are called before my NSXMLParser has completed it's run through the data, thus resulting in a blank table. I don't see any link in the pre-defined classes to self.tableView as cited in so many StackOverflow questions. How would I go about reloading the data in the RootViewController after the NSXMLParser completes its job?

EDIT I've set up some NSLog points in my code, and you can see by this console output that the UITableViewDelegate methods are being called before the array has any object

2011-05-23 19:41:17.591 appname[2804:207] numberOfSectionsInTableView array count: 0
2011-05-23 19:41:17.596 appname[2804:207] numberOfSectionsInTableView array count: 0
2011-05-23 19:41:17.600 appname[2804:207] numberOfSectionsInTableView array count: 0
2011-05-23 19:41:17.610 appname[2804:7303] callParse array count: 2
2011-05-23 19:41:19.911 appname[2804:207] hudWasHidden array count: 2

EDIT2 Let me clarify more: how can I create some sort of connection to the UITableView on the left side of the window created with the Split-View template? It's not created in Interface Builder, so I can't do an IBOutlet.

esqew
  • 42,425
  • 27
  • 92
  • 132

2 Answers2

1

If you can't have a pointer to the tableView, simply use delegation or notifications to tell your RootViewController to reload the data.

The simply approach would be notifications here I think. Check the official documentation.

In a nutshell, you add look for notification by registering for them like this in the RootViewController :

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(xmlDidFinish:)
    name:@"finishXML" object:nil];

And in your XMLParser, you actually post the notification when you're done like this

[[NSNotificationCenter defaultCenter]
    postNotificationName:@"finishXML" object:self];
gcamp
  • 14,622
  • 4
  • 54
  • 85
0

UITableView has a method reloadData which will call the tableViews delegate methods again (thus repopulating the table). Once the parser completes it's job, call [tableView reloadData] where tableView should be replaced with your UITableView instance.

Nitrex88
  • 2,158
  • 2
  • 21
  • 23
  • I know that, but I don't have any pointers to the table I need to reload the data into, that was basically my question. – esqew May 24 '11 at 01:25