func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let mostRecentLocation = locations.last else {
return
}
print(mostRecentLocation.coordinate.latitude)
print(mostRecentLocation.coordinate.longitude)
Timer.scheduledTimer(timeInterval: 60.0, target: self, selector: #selector(StartTestVC.sendDataToServer), userInfo: nil, repeats: true)
}
func sendDataToServer (latitude: Double, longitude: Double) {
SFUserManager.shared.uploadPULocation(latitude, longitude:longitude)
}
我希望每1分钟向服务器发送一次数据。我正在使用Timer.scheduledTimer并设置选择器。但我怎么能发送经纬度/经度函数?如何在定时器选择器上传递参数
你可以把你的位置作为类变量,并发送 –
是的,我知道要通过选择送? – pmb
@pmb你只需要摆脱输入参数并直接在函数内部使用类属性。请参阅下面的答案。 –