1

My game is always crashing when a location window pops up.

-(void) MyFunction
{
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
    [locationManager startUpdatingLocation];
}

Whenever it crashes, it returns to main with error EXC_BAD_ACCESS. However, I don't receive any stack trace to find out my problem. Neither the zombie provide stack trace.

One interesting thing is, this crash only happens on the iOS Simulator under release mode. If I change it to debug mode, it works perfectly. If I run it on the devices with release mode, it works perfectly. If I commented out [locationManager startUpdatingLocation], it works perfectly.

How can I resolve this?

bneely
  • 9,083
  • 4
  • 38
  • 46
  • 2
    Are you using ARC? Check and see if locationManager is being deallocated before startUpdatingLocation – jmstone617 Jan 14 '13 at 18:17
  • 4
    is locationManager defined with @property (strong) or assign? – Jano Jan 14 '13 at 18:27
  • Do you even enter in the delegate methods or you crash inside MyFunction? – Ramy Al Zuhouri Jan 14 '13 at 18:48
  • Could you set the Optimization Level to "Fastest, Smallest [-Os]" from your Project -> TARGETS -> [Your Target] -> Build Settings tab -> Apple LLVM compiler 4.1 - Code Generation section, and see if you can reproduce the error from debug mode? Often times, the optimization level hides defects from Debug mode. – Jason Huh Jan 14 '13 at 19:45
  • Hello all three: 1. no, it's not deallocated before startUpdatingLocation. 2. locationManager is not defined with @property or assign, it is a regular attribute in my class. 3. I added all the delegate functions; I put breakpoint everywhere so it uses didChangeAuthorizationStatus. However, it always call didFailWithError. And also, thank you all three! – Christina_Infinidy Jan 14 '13 at 21:06
  • Hello Jason Huh,: I did what you describe, but the game runs perfectly under debug model without any error. Thank you very much. – Christina_Infinidy Jan 14 '13 at 21:13
  • What is a 'regular attribute' that is created without being an @property? That sounds doubtful. – tooluser Mar 12 '13 at 19:58

0 Answers0