Kodeco Forums

Video Tutorial: MapKit and Core Location Part 2: Background Updates

Learn how to receive background updates, deferred updates, and how to get a singular location using Core Location.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3356-mapkit-and-core-location/lessons/3

Hello, great tutorial about Core Location. Nevertheless i have a question. How i can implement the location in background when the app is killed, or the phone is restart?. That topic i can understand very well. Can you give some idea.

hi there, great tutorial, but I have an error that is not allowing me to run the app. Towards the end of the code, I wrote:

“locationManager?.requestLocation”

However, this error popped out:

'Value of type ‘(CLLocationManager, CLAuthorizationStatus) → ()’ has no member ‘requestLocation’

may you please give me some advice on how to solve this issue?
thanks.

@flora_land requestLocation() is a method, not a property of the CLLocationManager class, so you call it on the locationManager object like this:

locationManager?.requestLocation()

Please let me know if you have any other questions or issues about the whole thing. Thank you! :]

hi again, another issue has popped up, even though I have followed the video and advice.

Cannot use optional chaining on non-optional value of type ‘(CLLocationManager, CLAuthorizationStatus) → ()’ Replace ‘?’ with ‘’

Is this because I am using swift 4? I have an option to fix the above issues by omitting the question mark, but the previous issue would pop-up.

Thaks for your help!

@flora_land Please check out the video tutorial’s sample project and let me know if you still have questions or issues after that. Thank you! :]

@shogunkaramazov I have tried to run the sample project, but I am not able to. One pop-up wrote:
31 AM

Do I have to download use Swift 2 and download Xcode 9?

Thanks for all the help

The tutorial appears to have been written for an older version of Swift since it was written back in 2016, if I’m not mistaken. So yes, when Xcode offers to fix the code, you should generally go with the fix :slight_smile:

However, sometimes if the original code was for Swift 2, the fixes might be confusing or even incorrect. Unfortunately, not sure how you could proceed in that situation.

In this particular instance though, using the Xcode suggested fix should work since I believe the code you need is:

locationManager.requestLocation()