位置管理器上的计时器

Timer on Location Manager

是否可以在 Timer 中调用 didUpdateLocations?我的意思是..

_timer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(_:didUpdateLocations:)), userInfo: nil, repeats: true) 

这行得通吗?如果是,那么它将每 10 秒更新一次位置?

您不能调用 didUpdateLocations。如果你想要经常更新,你最好的选择是标准定位服务:

The standard location service is most appropriate for apps that deliver location-related information directly to the user but it may be used by other types of apps too. To start the service, configure the desiredAccuracy and distanceFilter properties of the location manager and then call the requestLocation(), startUpdatingLocation(), or allowDeferredLocationUpdates(untilTraveled:timeout:) method. Never specify an accuracy value greater than what you need. Core Location uses the accuracy value you specify to manage power better. A higher degree of accuracy requires more precise hardware like GPS, which consumes more power.

https://developer.apple.com/reference/corelocation/cllocationmanager

您的回调选择器必须具有不同的签名:

class MyClass {

    func startTimer() {
        _timer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(MyClass.timerCallBack(_:)), userInfo: nil, repeats: true)
    }

    // ...

    func timerCallBack(timer: Timer) {
        // Here you go.
    }
}

(可能包含一些语法错误;目前手头没有 Xcode)