0

I'm new to programming in swift code and was hoping someone could help me with my project.

I would like to create an activity tracker that logs a users time and distance. Overall there is a total (say 200,000km) from London to Australia to achieve, routing through a few countries along the way.

Each time a user records an activity the total is reduced by the amount the user has recorded until the total is zero.

Secondly, I would like to show the overall progress on a map and record the progress from start.

I started by following a tutorial online that seems to be a good start. But I don't know how to log distance and time, and then do the bits above

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
    let location = locations[0]

    let span:MKCoordinateSpan = MKCoordinateSpanMake(0.01, 0.01)

    let myLocation:CLLocationCoordinate2D = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
    let region:MKCoordinateRegion = MKCoordinateRegionMake(myLocation, span)
    Map.setRegion(region, animated: true)

    self.Map.showsUserLocation = true
}

Any help would be greatly appreciated.

Kind Regards,

Nay
  • 11
  • 4

1 Answers1

0

Have you contemplated using a database to store the data?

The tree would have a branch for each user with 3 sub-branches (Time, Distance, DistanceLeft)

Then once the users distance is updated simply do the algorithm the return the distanceLeft and show that to the user

You can also use MKMap Annotations to log the distance traveled

Firebase would be a great place to start to store and log your data.

  • Can you expand your answer to explain how to use the tools you mentioned? Just giving the name of the tools isn't really enough detail for an answer on this forum. – mypetlion Feb 05 '19 at 19:35