swift - iOS Simulator Custom Location issues -


i having issues ios simulator , custom location setting iphone. when run app first time simulator opened finds location of user without issues, if change custom location, , run app again gives same location first time, despite having changed custom location. if instead set debug> location > none in simulator, , change location in product > schemes > edit schemes in xcode itself, have no issues. every time change location way have first set location none in simulator. problem code, or quirk of simulator wouldn't find real iphone?

import uikit import corelocation import mapkit var userlocationcity : string! var userlocationdate : string! var safeusername : string! class tinderviewcontroller: uiviewcontroller, cllocationmanagerdelegate    {  override func viewdidload() {     super.viewdidload()      pfgeopoint.geopointforcurrentlocationinbackground { (geopoint: pfgeopoint!, error: nserror!) -> void in          if error == nil {             println(geopoint)              var longitude :cllocationdegrees = geopoint.longitude             var latitude :cllocationdegrees = geopoint.latitude              var location = cllocation(latitude: latitude, longitude: longitude) //changed!!!             println(location)             var formatter: nsdateformatter = nsdateformatter()             formatter.dateformat = "dd-mm-yyyy"             let stringdate: string = formatter.stringfromdate(nsdate())             userlocationdate = stringdate              println(userlocationdate)              clgeocoder().reversegeocodelocation(location, completionhandler: {(placemarks, error) -> void in                  if error != nil {                     println("reverse geocoder failed error" + error.localizeddescription)                     return                 }                  if placemarks.count > 0 {                     println(userlocationcity)                     let pm = placemarks[0] clplacemark                     println(pm.locality)                      println(userlocationcity)                     userlocationcity = pm.locality                     println(userlocationcity)                     user["location"] = userlocationcity                     user.save()                      let string1 = pfuser.currentuser().objectid                     let string2 = "id_"                     safeusername = string2 + string1                      var locate = pfobject(classname: safeusername)                     locate.setobject(userlocationcity, forkey: "location")                     locate.setobject(userlocationdate, forkey: "date")                     locate.saveinbackgroundwithblock {                         (success: bool!, error: nserror!) -> void in                          if success == true {                             println("score created id: \(locate.objectid)")                         } else {                             println(error)                         }                                            }                 }                 else {                     println("problem data received geocoder")                 }             })             // user["location"] = geopoint            // user.save()         }     } } 

yes, sounds issue using 2 different methods simulate location. should choose either simulate location via schemes or via debug menu in xcode, not through both. sounds you're doing both, , setting in debug menu overriding setting in scheme.

i strongly advise you, however, test location based code on actual device. of problems find location services not appear on simulator; need deal actual peculiarities of real-world gps hardware.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -