2012-07-25 126 views
0

我从这个例程(IBAction)curr:(id)发件人崩溃。 所以我可以确定哪个按钮叫它。 当我按下调用上述方法(curr)的按钮时发生崩溃。 它必须显示当前的用户位置,但它会显示经度和纬度后立即崩溃。 接收到的数据串由于未捕获的异常终止应用程序ipad/iphone

{ 
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); 
} 
} 
+1

学习在代码中设置断点并使用XCode提供的调试工具。他们在那里是有原因的。他们会帮助你。你将能够自己解决这样的问题。为什么在SO上发布了如此多的问题,甚至人们甚至没有尝试过使用这些调试工具? – 2012-07-25 09:09:31

+0

是的,确切地说......设置断点并找到那个狗屎在哪里 – hacker 2012-07-25 09:26:31

回答

0

您可以检查您的.xib文件,然后通过第一个响应右键点击选中第一个响应立方体符号。 如果第一响应者连接插座中有任何警告符号,那么这是应用程序崩溃的原因。

相关问题