TableView model updated asynchronously sometimes crashes the app

In my app I am fetching RESTful data asynchronously from mutiple servers and merge the responses into an array when they are available: let respModel = [responses] I use didSet to check whether respModel is set and then trigger myTableView.reloadData() to udpate the table view each time

Sporadically, my app crashes during table view refresh and I think it's because two RESTful api calls arrive at exactly the same time, creating a deadlock on the respModel

I want to keep the current async functionality in, to get my table view updated whenever a fresh response arrives, but I also want to find a solution to the deadlock problem.

What's the best way to handle it?

I think it's because two RESTful api calls arrive at exactly the same time, creating a deadlock on the respModel

I don’t follow your logic here. I assume that you integrate both of these results into your model on the main thread — because that’s the only place it’s safe to call reloadData() — in which case they are automatically serialised.

What does your crash look like? Do you have a crash report handy? If so, please post it here. See Posting a Crash Report for advice on how to do that.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

TableView model updated asynchronously sometimes crashes the app
 
 
Q