DAve
DAve

Reputation: 353

UITableViewCell - update cell after table has been drawn

I have a UITableView cell - I'm pulling info in from a network, and I have the following delegate method:

-(void)dataReturned:(NSString*)data indexPath:(NSIndexPath*)indexPath
{
        MyTableViewCell *currentCell = (MyTableViewCell*)[self tableView:self.tableView cellForRowAtIndexPath:indexPath];

        currentCell.someInfo.text = data;
        currentCell.smallActivityIndicator.hidden = YES;
}

but unfortunately neither "someInfo" nor the smallActivityIndicator seem to be updated.

Any suggestions as to what I'm doing wrong?

Thanks!

Upvotes: 2

Views: 3830

Answers (2)

Jonathan Arbogast
Jonathan Arbogast

Reputation: 9650

Are currentCell, someInfo or smallActivityIndicator equal to nil?

Are you caching 'data' elsewhere or are you relying on MyTableViewCell to store your data? You should probably be storing that string elsewhere.

Upvotes: 0

albertamg
albertamg

Reputation: 28572

Instead of getting the cell object and updating it, you could update your model with the new data and then call reloadRowsAtIndexPaths:withRowAnimation: (reference). Reloading a row causes the table view to ask its data source for a new cell for that row. cellForRowAtIndexPath: will get called and it will construct a cell object from the model (which already has the new data).

Upvotes: 8

Related Questions