5

I have a tableview controller where the data for this table comes in from HTTP requests. When new data comes in (which should be reflected as new rows in my table), but when I call

[self.tableView reloadData]

nothing changes in the table. No new rows! I have log statements in my datasource methods confirming that after I call reloadData, the table asks how many rows and sections to draw. My controller for sure returns the new number of rows like it should, but the table doesn't seem to care. I also checked to make sure my cellForRow... method returned a proper instance of the cell that has been configured with the proper data object. I've never had this problem before!

I'm running iOS 4.2 in the simulator with an iPad app built for 4.2.

Samuel Goodwin
  • 1,698
  • 13
  • 17
  • I should add that -some- of the time the new row does actually show up. There's a less than 50% chance the new row will show though. – Samuel Goodwin Mar 18 '11 at 17:15
  • Pssst, you can just edit your original question, rather than add comments to clarify. – Conspicuous Compiler Mar 18 '11 at 17:35
  • Also, if this is a multi-threaded thing, [this previous SO question may be relevant](http://stackoverflow.com/questions/2322547/redraw-uitableview-after-updating-data). – Conspicuous Compiler Mar 18 '11 at 17:52
  • I checked and the call to reloadData is for sure happening on the main thread every time. Even did like that question suggested and explicitly told the tableView to performSelectorOnMainThread. Still not working. – Samuel Goodwin Mar 18 '11 at 19:50
  • If you can file a bug at bugreporter.apple.com and attach your project, that would be very helpful. Make sure to repost the bug # here. That way, we could look to see if this is a UITableView bug, or something that you're doing incorrectly. – Ian Baird May 15 '11 at 18:02

3 Answers3

1

Perhaps you may have more than one tableview? You could print pointers of the table from the didSelectRowAtIndexPath: and cellForRowAtIndexPath: delegate methods. Including the description of your self.tableView could also shine some light on the issue.

1

Sounds like the old model/view confusion. reloadData will merely re-display the data that is already in the data source, not load in new data. You can call

[yourFetchedResultsController performFetch:&*error];

everytime new data is available, to force an immediate update. As you saw, the NSFetchedResultsController will update its results, but when and how often is dependant on whether it has a delegate and whether the cache file name is set. I quote from NSFetchedResultsController Class Reference:

In addition, NSFetchedResultsController provides the following features:

It optionally monitors changes to objects in its associated managed object context, and reports changes in the results set to its delegate (see “The Controller’s Delegate”). It optionally caches the results of its computation so that if the same data is subsequently re-displayed, the work does not have to be repeated (see “The Cache”).

A controller thus effectively has three modes of operation, determined by whether it has a delegate and whether the cache file name is set.

  1. No tracking: the delegate is set to nil. The controller simply provides access to the data as it was when the fetch was executed.

  2. Memory-only tracking: the delegate is non-nil and the file cache name is set to nil. The controller monitors objects in its result set and updates section and ordering information in response to relevant changes.

  3. Full persistent tracking: the delegate and the file cache name are non-nil. The controller monitors objects in its result set and updates section and ordering information in response to relevant changes. The controller maintains a persistent cache of the results of its computation.

Elise van Looij
  • 4,162
  • 3
  • 29
  • 52
  • Nope. As I stated before, my controller is definitely returning values in the UITableViewDataSource methods that reflect the new data, but the table just isn't bothering to display then new content. The project's data is stored in a weird way, so the controller does some manual sorting/storing of this data. I know the difference between a model and a view and this view is not correctly drawing the information my controller is feeding it. – Samuel Goodwin Mar 30 '11 at 04:03
0

Are your row heights > 0.0? What does tableView.visibleCells return? I'd verify that my cells have hidden != YES and that frame.size > (0x0)

nielsbot
  • 15,922
  • 4
  • 48
  • 73