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 に答える