0
我希望你們能幫助我,因爲我的思維燃燒着大腦:D。 我想通知用戶,例如每100米。但我不想更改位置服務的刷新。有一個簡單的方法,但我不好。我認爲有一個更好的解決方案。 我做的,到目前爲止(這是僞代碼!)這就是所謂的didUpdateLocation斯威夫特地點:每X米火災通知
//We want notify User but only 5 times during the movement
if distanceToReport < settedDistance {
//Store that first Notification is fired
if !firstNotificationFired {
self.notifyUser(report: report)
}
if firstNotificationFired && distanceToReport <= 400 {
//Store that second Notification is fired
self.notifyUser(report: report)
} else if secondNotificationFired && distanceToReport <= 300 {
//Store that third Notification is fired
} else if thirdNotificationFired && distanceToReport <= 200 {
//Store that fourth Notification is fired
} else if fourthNotifiationFired && distanceToReport <= 100 {
//Store that fifth Notification is fired
}
}
難道還有比這更好的和有效的方法是什麼?或者有什麼數學或算法可以幫助?
到目前爲止感謝。