2011-11-17 38 views
1

我收到用戶的報告,說我的應用程序在啓動時崩潰。目標C - CLLocationManager崩潰

所以我得到了崩潰報告。用戶在iOS 4.1上。

崩潰日誌如下:

Thu Nov 17 12:23:49 unknown AppName[1481] <Error>: +[CLLocationManager authorizationStatus]: unrecognized selector sent to class 0x3e2ee618 
Thu Nov 17 12:23:49 unknown AppName[1481] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[CLLocationManager authorizationStatus]: unrecognized selector sent to class 0x3e2ee618' 

似乎無法看到什麼錯我的代碼,這裏是我

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 
    // 4.2 and below 

    NSLog(@"locationManager error = %@", error); 
    if ([error code] != kCLErrorLocationUnknown) { 
     [self stopUpdatingLocation:NSLocalizedString(@"Error", @"Error")]; 
    } 
} 

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status 
{ 
    // 4.2 & above 
    NSLog(@"authorization change = %i", status); 
} 

- (void)stopUpdatingLocation:(NSString *)state { 
    NSLog(@"stop updatinglocation = %@", self.bestEffortAtLocation); 
    [locationManager stopUpdatingLocation]; 
    locationManager.delegate = nil; 
} 

請微啓。

謝謝
三通

回答

7

我不認爲錯誤是在你列出的代碼,放到你試圖訪問
+[CLLocationManager authorizationStatus]這是4.2+方法,所以沒有出現錯誤消息驚喜在那裏,你有幾個選擇。你可以檢查到respondsToSelector:首先,或者運行@try {}塊內的代碼。任何一個人都不應該讓你崩潰。

+0

D'oh,謝謝... – teepusink