Wednesday, April 6, 2011

Updating Cell Data in UITableView

Today I created a subclass of UITableView which would display a list of RSS feed items.  After creating a custom parser with the necessary callbacks to inform the UITableView subclass after parsing each item and when the feed was finished being parsed, the table needed to be updated to display the RSS items that were pulled from the XML feed.  I struggled with this a bit and tried calling setNeedsDisplay at first thinking that it would cause the view to repaint along with the new data, but that didn't work.  So I hopped onto Google and found that when the underlying data for the table changes a call to the reloadData method on the UITableView instance is required.  After doing this everything worked as expected.  Of course afterwards this all made perfect sense, but these kinds of moments are sure to occur frequently as I learn the iOS frameworks.

No comments:

Post a Comment