在iPhone模拟器问题中测试GPS

时间:2010-07-30 09:39:04

标签: iphone gps core-location

我在iPhone模拟器中发现了一些关于测试GPS(重定位)的文章。 这似乎很简单,但我不能让它工作。

我得到的错误信息是:


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

我使用的代码是:


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];

我希望有人可以帮我解决这个问题,因为它肯定会节省大量的时间来测试

2 个答案:

答案 0 :(得分:1)

不应该是[[CLLocation alloc] init...];而不是[[CLLocation init] init...];吗?

答案 1 :(得分:0)

结果导致下一行导致错误


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]];

我改为:


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