views:

264

answers:

2

I found some various articles about testing the GPS (corelocation) in the iPhone simulator. It seems pretty straightforward, but i can't get it to work.

The error message i'am getting is:


2010-07-30 11:20:16.372 appname[50954:207] *** +[CLLocation initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:]: unrecognized selector sent to class 0x32081320

2010-07-30 11:20:16.373 appname[50954:207] CoreAnimation: ignoring exception: *** +[CLLocation initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:]: unrecognized selector sent to class 0x32081320

the code i'am using is:


self.locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.distanceFilter = 100.0f;
locationManager.desiredAccuracy= kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];

// test simulator location once
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updateTestLocation) userInfo:nil repeats:NO];


-(void)updateTestLocation{

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

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

[self locationManager:nil didUpdateToLocation: sampleLocationUpdate fromLocation: nil];
//[self locationManager:locationManager didUpdateToLocation: sampleLocationUpdate fromLocation: nil];

i hope someone can help me fix this, because it sure will save a lot of time testing

A: 

Shouldn't it be [[CLLocation alloc] init...]; and not [[CLLocation init] init...];?

Tom Irving
i changed it, but it didn't effect the error. Any idea what else it could be?
Martijn
The error is saying that the initWith... method doesn't exist for CLLocation. Check the spelling of your method. Post the new error as well as it cannot be the same.
Tom Irving
A: 

It turn out the next line was causing the error


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

CLLocation *sampleLocationUpdate = [[CLLocation alloc] initWithCoordinate: newlocation altitude:100 horizontalAccuracy:100 verticalAccuracy:100 timestamp:[NSDate date]];

i changed it to:


CLLocation *sampleLocationUpdate = [[CLLocation alloc] initWithLatitude:37.0 longitude:127.0];
Martijn