Reputation: 9672
I have a custom UITableViewCell with, among other things, a label and an imageView. If the table view is the visible view and it has a cell on it, if I programmatically update the label's text and the imageView's image and log when I do it, it takes about 4 seconds AFTER I see the notification in the logs for the label and image to update. Here is the order of what happens and how:
-Load the view containing the table and one custom cell
-Write a file to disk using and NSOperation (and queue)
-When the NSOperation is finished writing the file it fires a NSNotification (defaultCenter) which tells the cell's view to update the label and image AND I set [self setNeedsDisplay]
-Here I see in my logs that the cell has gotten the notification AND finished setting the new values
-~4 seconds later the cell's view actually updates.
What gives?
Upvotes: 2
Views: 727
Reputation: 9672
The solution to my particular problem hinged on the way in which I'm updating the data, I'm using an NSOperation (and queue) to send a notification, the notification responder then updates the view. Problem is an NSOperation technically lives on another thread so what I should have done is this:
-Write a file to disk using and NSOperation (and queue)
-When the NSOperation is finished writing the file it fires a NSNotification (defaultCenter), the responder should then performSelectorOnMainThread a method that does the actual updating of the view
Did this and my cell updates right away.
Upvotes: 4
Reputation: 77173
You should call reloadRowsAtIndexPaths:withAnimation: to update a particular cell in the table view.
Upvotes: 0