Best practice for updating table cells based on notifications

I have a tabular view of user cells representing individual downloads, and each cell has a progress indicator in it and a success / error icon. I want to update the cells as the progress updates and indicate if it was a success or a failure. I do this when my boot controllers broadcast NSNotifications for progress / success / failure.

Is it better:

A) so that each cell has an NSNotification listener for these notifications and updates the cell view

OR

B) , the table view controller has an NSNotification listener that listens for these notifications and then sets values โ€‹โ€‹for each cell, receiving cells with cellForRowAtIndexPath.

I think it comes down to A , itโ€™s easier to implement, but I wonder if there is a performance penalty so that so many listeners listen to these notifications and do โ€œIF this notification is related to me ...โ€ Unlike B , which has only one listener and can be generalized to any multi vs single listener project.

+6
objective-c iphone uitableview
source share
1 answer

You can configure key-value monitoring (KVO) to present a table for processing row updates, and then use it (with a custom subclass of UITableViewCell ) to update cells with information from your objects. See Using KVO for table updates for an example of using KVO to update a section / row.

+5
source share

All Articles