2011-11-17 41 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