2012-07-25 127 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文件,然後通過第一個響應右鍵點擊選中第一個響應立方體符號。 如果第一響應者連接插座中有任何警告符號,那麼這是應用程序崩潰的原因。

相關問題