Kurt
Kurt

Reputation: 855

Array not getting to cellForRowAtIndexPath

I am trying to parse an XML document and load the array into a table view.

In init I call initializeDatabase, which makes a URLRequest and Connection. Then I make a call to parseXML, which parses the document. All that seems to work well.

When done I want to load the results array into a table view. Not happening.

I have placed NSLog statement in each method to track this down, including the table view data source methods.

2011-02-01 07:29:17.770 Project[1664:207] initializeDatabase:
2011-02-01 07:29:17.814 Project[1664:207] numberOfSections
2011-02-01 07:29:17.815 Project[1664:207] results in numberOfRowsInSection: (null)
2011-02-01 07:29:18.560 Project[1664:207] Connection was made
2011-02-01 07:29:18.562 Project[1664:207] connectionDidFinishLoading:
2011-02-01 07:29:18.562 Project[1664:207] parseXML called
2011-02-01 07:29:18.563 Project[1664:207] parserDidStartDocument
2011-02-01 07:29:18.564 Project[1664:207] parserDidEndDocument:
2011-02-01 07:29:18.564 Project[1664:207] results: "ProjectData: 0x4e461b0"

The cellForRowAtIndexPath was not called. I'm not sure why.

Any ideas?

Kurt

Upvotes: 0

Views: 271

Answers (2)

joels
joels

Reputation: 7731

You could also use an NSArrayController and bindings. Set the contentArray to the array of parsed data, and bind the VALUE of each column. Make sure the dataSource on the tableView is NOT set to anything. You wont have to call reloadData each time now.

Upvotes: 0

Bjarne Mogstad
Bjarne Mogstad

Reputation: 1154

It sounds like you need to run the method reloadData on your table view after you have parsed the data. Reload data makes the table view ask its datasource how many rows it should display. The table view does this automaticlly on viewDidLoad, but in your case you don't have any data to display at that point. Therefor in parserDidEndDocument, run [tableView reloadData];

Other solutions, make sure both the delegate and datasource is set to right instance.

Upvotes: 1

Related Questions