Version 3.1, Chapter 4, Completion Handler for NSAsynchronousFetchRequest

Since the UI is being updated, shouldn’t the call to self.tableView.reloadData() be dispatched to the main queue as in:

DispatchQueue.main.async {
self.tableView.reloadData()
}

1 Like

@marathoner1234 Thanks very much for your question, and yes, you are indeed correct. The reason why the code may not be provided in an ideal, optimized structure as you presented is because the intent of the code is to teach the beginner on Core Data concepts, and introducing GCD/MultiThreading, while definitely is being used correctly in your example, could potentially confuse the reader, and open up a can of worms. The author typically assumes the reader is a novice, and assumes that they are not familiar with little more than the basics.

Less code = Less likely to cause confusion :wink:

I hope this makes sense!

Take care. :slight_smile: