emenegro
emenegro

Reputation: 6971

Reloading UITableView keeps old data

I have a custom view

MyView : UIViewController <UITableViewDelegate, UITableViewDataSource>

with a UITableView within (and some buttons and labels).

I have a notification from another view to populate the table with data form a sqlite3 database. I passed an array and after handle the notification I reload the table ([tableView reloadData]) with the new data (it has new data, I debug it).

Then it calls

(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

but doesn't refresh cells, it still old data. I debug and it reloads but doesn't refresh data.

What's the problem? Can I clear old cells or something like that?

Upvotes: 0

Views: 2396

Answers (1)

greenisus
greenisus

Reputation: 1707

It sounds like you're probably setting the data in your cell == nil block after dequeueing it. In that case, move it out of that block and be sure that the data is set on every single cellForRowAtIndexPath call.

Upvotes: 4

Related Questions