0

我从这个例程 (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);
}
}
4

1 回答 1

0

您可以检查您的 .xib 文件并通过右键单击急救人员立方体符号来检查急救人员。如果第一响应者连接插座中有任何警告符号,这就是您的应用程序崩溃的原因。

于 2012-07-25T11:16:17.443 回答