UIKit App. Chapter 22 This method can cause UI unresponsiveness

MyLocations Chapter 22 Start location updates

func startLocationManager() {

if CLLocationManager.locationServicesEnabled() {

I have this purple warning: that shows after adding: lastLocationError = nil

//here’s the message
This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.

Here’s the method:

func updateLabels()

I don’t know how to remedy is message, any help would be great. Thx

Does your UI stop responding though? If it doesn’t, then you should be fine for the moment to use that method as provided in the book.

If your UI does stop responding when you use the code in the book, could you please send a ZIP file of your project so that I can take a look?

1 Like

Hi Fahim, it still responds. I was wondering if there is a solution so as not to have to recode in the future. Thank you for your response. Cheers

The solution would be to implement the recommendation as per the waning :slightly_smiling_face: But I can’t tell you offhand as to whether that will resolve the issue or not since there might be some other issue/warning which pops up at that point.

I’d have to try the solution myself to be sure. I’ll add this as something to be done for the next release of the book. Thanks!

Worst part is that in testing I actually think it does cause UI Unresponsiveness. I really don’t think waiting for an update is a good solution.

As I mentioned previously, if it is causing unresponsiveness, please send me a zipped copy of the full project so that I can take a look. Also do note that there have been at least one if not two updates to Xcode since the book update. So whatever solution I provide would be for the current version of Xcode and might (or might not) work the same for the version of Xcode the book was written for.

Okay, I got it. Thanks.