testing GPS in iPhone simulator problem

拈花ヽ惹草 提交于 2020-02-07 04:57:25

问题


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


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/3370289/testing-gps-in-iphone-simulator-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!