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);
}
}
学习在代码中设置断点并使用XCode提供的调试工具。他们在那里是有原因的。他们会帮助你。你将能够自己解决这样的问题。为什么在SO上发布了如此多的问题,甚至人们甚至没有尝试过使用这些调试工具? – 2012-07-25 09:09:31
是的,确切地说......设置断点并找到那个狗屎在哪里 – hacker 2012-07-25 09:26:31