views:

561

answers:

1

I've been playing around with the iPhone SDK, using MapKit and Core Location.

What are some of the tricks you can use to better test things... while still on the simulator (long before I have to try it out on my iPhone).

Is there a way to use NSTimer and regularly get 'pretend' values for location, heading, speed, etc?

The simulator only giving 1 location... and no movement... really limits its 'testing' usefulness.

+4  A: 

It is normal way to receive the GPS data.

[GPS module] ----(CLLocationManagerDelegate)---> [YourLocationManager class]

locationManager:didUpdateToLocation:fromLocation:

This method will receive the data.


You can also call same method on YourLocationManager class from Test class.

[Test class] -------- call ------> [YourLocationManager class]

1.. make CLLocation object like this..... on Test class

CLLocationCoordinate2D location;
location.latitude = 37.0;
location.longitude = 127.0;

CLLocation *sampleLocation = [[CLLocation init] initWithCoordinate: location
        altitude:100
        horizontalAccuracy:100
        verticalAccuracy:100 
        timestamp:[NSDate date]];

you can set only latitude, longitude, altitude, hotizontal accuracy, vertical accuracy, timestamp.

you can't set... course, speed.

2.. call locationManager:didUpdateToLocation:fromLocation: method on YourLocationmanager class from Test class.

[yourLocationManager locationManager: nil or something
                     didUpdateToLocation: sampleLocation
                     fromLocation: sampleLocation or nil or something];

You can use NSTimer to send more data!!

cappuccino
`[[CLLocation init] initWithCoordinate:...]` should be `[[CLLocation alloc] initWithCoordinate:...]`
Thomas