views:

2002

answers:

3

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!!

A: 

According to the iPhone Development Guide, the location in the simulator is fixed. Sorry!

Dave DeLong
thats not my problem. on 3.2, the corelocation in simulator doesnt work. there is no "cupertino simulating". i edited my question
choise
+2  A: 

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.

progrmr
so ipad simulator doesnt give me a position by default?
choise
handled it with your link. see my question-post to see how i handled it.
choise
@choise: I just found out today that the simulator doesn't give a location when you have Airport (Wi-Fi) turned off on your Mac. At least with XCode 3.2.3 that is what's happening.
progrmr
huh, i have my airport disabled,yes. thanks! i'll give it a try.
choise
@progrmr, thanks for finding that, I was going spare trying to find out why everyone was getting the location Cupertino except for me. Not very eco though: I now have to have my Airport card switched on and drawing electricity though I don't use it for anything else (I use a network card for internet access).
Elise van Looij
I'm glad it helped, maybe you could up vote this answer then?
progrmr
A: 

I am using the iphone simulator 4.0, Xcode 3.2.3, on my iMac with Airport turned on (alltough my iMac is connected by ethernet cable to my wireless router -- I don't know what Airport has to do with anything -- the doc's say the location is fixed to Cupertino).

I get the error "The operation couldn't be completed. (kCLErrorDomain error 0.)"

This is code that has been working fine on previous versions of the simulator and an actual iPhone. Any ideas?

wcochran