0
私の脳は思考から燃えているので、皆さんが私を助けてくれることを願っています。 ユーザーに通知する必要があります。 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
}
}
で呼び出されないことは、これよりもはるかに優れたとefficent方法はありますか?または、数学的またはアルゴリズムが役立つかもしれませんか?
これまでのところありがとうございます。