@@ -11,7 +11,6 @@ import MapKit
1111
1212var userLatitude : Any ?
1313var userLongitude : Any ?
14-
1514class 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