1

I would like test on simulator, that a function is trigered, if the iPhone reaces specific speed. So the question is how can I simulate iPhone moving, with specific speed? Using gpx file?

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    double gpsSpeed = newLocation.speed;
    if (gpsSpeed > 30) {
        //myLogic
        [SomeClass function];
    }
}
Luda
  • 7,282
  • 12
  • 79
  • 139
  • question may have been answered here: http://stackoverflow.com/questions/802156/testing-corelocation-on-iphone-simulator – Jason Cragun Jul 24 '12 at 16:13
  • Look here, you need to use Automation tool from Instruments: http://stackoverflow.com/questions/9439495/when-using-gpx-in-xcode-to-simulate-location-changes-is-there-a-way-to-control/11709258#11709258 – Stanislav Dvoychenko Jul 29 '12 at 20:27
  • Please put that as a answer so I could mark it is as correct – Luda Jul 30 '12 at 05:07

1 Answers1

0

Do this:

  - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
        double gpsSpeed = 31;
        if (gpsSpeed > 30) {
            //myLogic
            [SomeClass function];
        }
    }

The simulator can't generate CLLocation objects for you. You can generate them yourself, but you'd essentially be doing the same thing as just telling the if statement to execute.

Dustin
  • 6,783
  • 4
  • 36
  • 53
  • you made me smile :))) I need to test the whole thing – Luda Jul 24 '12 at 17:14
  • The best solution is probably to add a button or other control that you can access that calls `[SomeClass function]`. Then you can run the app normally and simulate `gpsSpeed > 30` whenever you need to. You probably won't find a better solution for the simulator; I'm working on an app that includes core location right now and I just keep it running on my phone. – Dustin Jul 24 '12 at 17:24
  • I was told it should be done with a gpx file. I thought somebody could help me understand it – Luda Jul 25 '12 at 07:23