I have created a custom queue where I am doing some processing and thereby creating a array of some objects which is used by UITableView to reload itself. The custom queue in invoked for somewhere in my app and after the processing I am reloading my table view in the main UI queue. So far so good but while my table view is reloading the custom queue is called again thereby modifying my array. So I get the out of bound exception in cellforrowatindexpath method which is expected. How do I get rid of this type of concurrent issues with GCD. What are the prectices to use in these type of scenerio.
Share
Instead of adding the table reload to your main queue, try
[self performSelectorOnMainThread:@selector(doSomething:) withObject:object waitUntilDone:YES]That will reload the table on the main thread, but pause your custom queue until it is complete, thereby preventing the error you are experiencing.