Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Location in iPhone Simulator 3.2 (iPad)

So,

i'm trying to port my app to iPad. I'm using CoreLocation.

Apple says the iPad does have

Location:
Wi-Fi
Digital compass
Assisted GPS (Wi-Fi + 3G model)
Cellular (Wi-Fi + 3G model)

so it should be possible to get the position of my ipad (at least with 3g model) about 3km radius would be enought.

but it doesnt work in simulator (3.2 ipad) (running 3.1.3 in simulator simulates me cupertino).

is there a way to get the position in simulator (3.2 ipad) ? i live in germany and here the ipad isnt released yet, so i cannot test it on my device.

thanks!

edit

thats how i'm trying to get my connection

locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
locationManager.delegate = self;
[locationManager startUpdatingLocation];

and always on 3.2 locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error gets called. not on 3.1.3

error object looks like this:

Error Domain=kCLErrorDomain Code=0 "Operation could not be completed. (kCLErrorDomain error 0.)"

edit

so i handled it something like this:

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {

    #ifdef TARGET_IPHONE_SIMULATOR
    // Cupertino
    CLLocation *simulatorLocation = [[CLLocation alloc] initWithLatitude:37.33168900 longitude:-122.03073100];
    [self locationManager:locationManager didUpdateToLocation:simulatorLocation fromLocation:nil];
    [simulatorLocation release];
    #else
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ErrorNotification"  object:NSLocalizedString(@"GPS-coordinates could not be detected",@"")];
    #endif

}

It is very messy but works.

edit2: try enabling your Airport, this could also solve the problem!!

like image 826
choise Avatar asked May 15 '10 17:05

choise


1 Answers

Yes, see this question which has several good answers to this.

EDIT - I eventually decided to write my own CLLocationManager simulator for testing on the iPhone simulator. It's located on github here if you want to use it.

like image 90
progrmr Avatar answered Oct 12 '22 21:10

progrmr