我从这个例程 (IBAction)curr:(id)sender 中遇到了崩溃。所以我可以确定哪个按钮调用它。当我按下调用上述方法(curr)的按钮时发生崩溃。它最终必须显示当前用户位置,但在显示纬度和经度后立即崩溃。以字符串形式接收数据
{
Error = "Lat must be provided";
Success = 0;
}
它抛出异常:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6e20000'
这是我的代码:
-(IBAction)curr:(id)sender
{
count=0;
NSLog(@"fhfg");
NSLog(@"%@",latu);
NSLog(@"%@",longs);
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
if (count==0)
{
int degrees = newLocation.coordinate.latitude;
double decimal = fabs(newLocation.coordinate.latitude - degrees);
int minutes = decimal * 60;
double seconds = decimal * 3600 - minutes * 60;
latu= [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds];
//a=latu;
NSLog(@" Current Latitude : %@",latu);
//latLabel.text = lat;
degrees = newLocation.coordinate.longitude;
decimal = fabs(newLocation.coordinate.longitude - degrees);
minutes = decimal * 60;
seconds = decimal * 3600 - minutes * 60;
longs = [NSString stringWithFormat:@"%d° %d' %1.4f\"", degrees, minutes, seconds];
NSLog(@" Current Longitude : %@",longs);
}
}