Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c CLLocationManager在发布模式但非调试模式下因错误EXC_BAD_访问而崩溃_Objective C_Memory Management_Exc Bad Access_Cllocationmanager_Release Mode - Fatal编程技术网

Objective c CLLocationManager在发布模式但非调试模式下因错误EXC_BAD_访问而崩溃

Objective c CLLocationManager在发布模式但非调试模式下因错误EXC_BAD_访问而崩溃,objective-c,memory-management,exc-bad-access,cllocationmanager,release-mode,Objective C,Memory Management,Exc Bad Access,Cllocationmanager,Release Mode,当位置窗口弹出时,我的游戏总是崩溃 -(void) MyFunction { locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers; [locationManager startUpdatingLocation];

当位置窗口弹出时,我的游戏总是崩溃

-(void) MyFunction
{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
    [locationManager startUpdatingLocation];
}
每当它崩溃时,它返回main,返回错误EXC_BAD_ACCESS。但是,我没有收到任何堆栈跟踪来发现我的问题。僵尸都不提供堆栈跟踪

一件有趣的事情是,这种崩溃只发生在iOS模拟器的发布模式下。 如果我把它改为调试模式,它会工作得很好。如果我在具有释放模式的设备上运行它,它将完美工作。如果我将[locationManager startUpdatingLocation]注释掉,那么它可以完美地工作


如何解决此问题?

是否使用ARC?检查并查看是否在StartupDatingLocationLocationManager使用@property strong或assign定义之前解除分配locationManager?您是否输入委托方法或在MyFunction中崩溃?您是否可以将优化级别设置为项目->目标->中最快、最小的[-Os]->“构建设置”选项卡->Apple LLVM编译器4.1-代码生成部分,并查看是否可以从调试模式复制错误?通常情况下,优化级别会在调试模式下隐藏缺陷。不,在startUpdatingLocation之前不会解除分配。2.locationManager未使用@property或assign定义,它是我的类中的常规属性。3.我添加了所有的委托函数;我将断点放在所有地方,因此它使用didChangeAuthorizationStatus。然而,它总是叫迪德罗。还有,谢谢你们三位!