Background:
I have a tableview displaying about 8 sections each backed with my own PlaceList class representing a list of objects (the implementation uses an NSMutableArray). There are around 200 objects in total. Each section corresponds to how far away the object is from the current location (e.g. within 1 mile, within 10, 25, 50...etc).
Every now and then, I need to respond to asynchronous notifications from CoreLocation that require me to recalculate which section each object belongs in, update the distance for each object (which is displayed in each cell), and also resort each list, then reload the table view. I also do this operation in viewWillAppear.
Within the operation that performs the update (a method on PlaceList) I've used @synchronized(self) in case it gets invoked from more than one thread by the OS (I don't use another thread for it myself at present). However, currently this operation results in the UI feeling 'frozen' from time to time, so I'm looking at ways to do it in its own thread.
Question:
What's the best way to do this kind of long running operation on the data backing a table view? As far as I can see it is not safe to spin off a background thread to do the operation, as even if I use performSelector to reload the table view on the main thread when done, it is still possible that the user will tap a cell while the operation is running and the data is not consistent with the display. And adding any kind of locking would just defeat the purpose.
Do the UI and CoreLocation locationManager send their notifications on the same thread, i.e. can I safely dispense with the @synchronized(self) on the PlaceList?