Skip to content

Commit b40649c

Browse files
author
Granwyn Tan
committed
More Bug Fixes for Location
1 parent e9bed51 commit b40649c

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Reserva/GetLocationViewController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import MapKit
1111

1212
var userLatitude: Any?
1313
var userLongitude: Any?
14-
1514
class GetLocationViewController: UIViewController, CLLocationManagerDelegate {
1615

1716
var currentLocation: CLLocationCoordinate2D?
@@ -23,6 +22,8 @@ class GetLocationViewController: UIViewController, CLLocationManagerDelegate {
2322
super.viewDidLoad()
2423

2524
// Do any additional setup after loading the view.
25+
26+
defaults.set(false, forKey: "setLocationAlready")
2627
}
2728
override func viewDidAppear(_ animated: Bool) {
2829
self.locationManager.requestWhenInUseAuthorization()
@@ -52,10 +53,14 @@ class GetLocationViewController: UIViewController, CLLocationManagerDelegate {
5253
}
5354

5455
@IBAction func nextClick(_ sender: Any) {
55-
locationManager.stopUpdatingLocation()
56-
defaults.set(userLatitude, forKey: "userLatitude")
57-
defaults.set(userLongitude, forKey: "userLongitude")
58-
self.performSegue(withIdentifier: "seeAccount", sender: nil)
56+
let setLocationAlready = defaults.bool(forKey: "setLocationAlready")
57+
if setLocationAlready != true {
58+
locationManager.stopUpdatingLocation()
59+
defaults.set(userLatitude, forKey: "userLatitude")
60+
defaults.set(userLongitude, forKey: "userLongitude")
61+
self.performSegue(withIdentifier: "seeAccount", sender: nil)
62+
defaults.set(true, forKey: "setLocationAlready")
63+
}
5964
}
6065

6166
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

0 commit comments

Comments
 (0)