I have a method (myMethod) in a class (myClass) which utilizes the CLLocationManager to startMonitoringSignificantLocationChanges(). MyClass is the delegate of the CLLocationManager and I have implemented the didUpdateToLocation() method.
What I want to do is call startMonitoringSignificantLocationChanges() from within myMethod, then once didUpdateToLocation() has been called and completed I want to continue working in myMethod. Is this possible?
I won’t say that it’s impossible, but I strongly urge you to embrace the asynchronous nature of how this works, and to find another way to do what you’re trying to do. Like split up
myMethodinto “before” and “after” parts, and let your delegate trigger the “after”. This is a really common pattern in Cocoa/iOS, and you’ll be happier in the long run not fighting the framework.This is especially true if
myMethodis something that’s running on the main thread, because blocking that thread while waiting for location updates will lock up your entire UI. Take too long, and the system will kill your app.