I am trying to implement the UIActivityIndicator as an accessory view inside of a UITableView when a user selects a cell but sometimes it bugs out when the user selects something.
Right now my pseudocode is like this:
- User selects cell
- Cell sets accessory view
-
Calls exhaustive method in background thread
-
In background thread:
- Call exhaustive method in other class
- Remove accessory view in main thread
When the exhaustive method is called, a key-value observer sees the method is complete and pops the whole UITableView. When it trips out, sometimes the selection would move back and forth from the selected cell to the previous selected cell very rapidly. Other times it would erase the cell itself.
Additonal information:
Well in the background thread, it is performing a method from another class that retrieves data from an API. A property is set in that method to tell an observer the method is done. Once the observer sees this it pops the UITableView. I am not doing any table manipulation in the background thread, it is all done in a callFromMainThread inside of the background thread’s selector.
Without code, hard to say precisely what is going on.
The question, though, indicates what is most likely; you are manipulating UIKit state from a thread in a fashion that isn’t supported. In general, any manipulation of the UI must be done in the main thread unless explicitly documented as being safe to do from a background thread.