Problem simulating a location

Alan Stenhouse alanstenhouse at
Mon Apr 13 19:20:20 EDT 2020

Hi Graham

IIRC, mobileSensorReading() returns an array so you need to check the keys of the array.


if tSensorData["latitude"] is empty then




> On Mon, 13 Apr 2020 14:38:56,Graham Samuel <livfoss at <mailto:livfoss at>> wrote:
> I?m trying to use the 10.2 XCode simulator to test an iOS app that uses the phone?s ability to know its location (usually via GPS). I can run the simulation and show that it?s working in a general way. Furthermore, mobileSensorAvailable("location?) responds in the simulated app, saying the sensor is ?authorizedWhenInUse?
> However the following button handler - adapted from a lesson by Devin Asay (very sincere thanks for all that, Devin!) always returns an empty result. I have set the location in the simulator to a (genuine) custom location, but if I choose one of the built-in locations, I still get the same result.
>  On mouseUp
>    mobileStartTrackingSensor "location? -- enable the sensor first
>    put "now trying to get a one-off location reading" & return after fld ?TheReport"
>    put mobileSensorReading("location",false) into tSensorData -- this returns a string with the current latitude, longitude and altitude
>    mobileStopTrackingSensor ?location? -- turn off the sensor when done
>    if tSensorData is empty then
>        put "no location info!!" & return after fld "TheReport"
>    else
>        put tSensorData & return after fld "TheReport"
>   end if
> end mouseUp

More information about the use-livecode mailing list