Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086392
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:43:13+00:00 2026-05-20T18:43:13+00:00

This might be one of those silly question where, once a solution is pointed

  • 0

This might be one of those silly question where, once a solution is pointed out, makes you feel pretty stupid wondering how you didn’t see it but I can’t figure out why this part of my app is crashing with EXC_BAD_ACCESS (and no stack trace).

I have a CLLocationManager *locationManager (ivar declared in interface file) that gets created on viewDidLoad if locationServices is enabled:

- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([CLLocationManager locationServicesEnabled])
    [self findUserLocation];
    ...
}

#pragma mark - Location finder methods

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

So the location manager starts updating location and each time and update is found, the delegate method below is called, where I check to see if I should time out or continue looking for my desiredAccuracy:

#pragma mark - CLLocationManager delegates

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    if ([newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp] > 8)
        [self locationManagerTimeOut];
    else if ((newLocation.horizontalAccuracy <= manager.desiredAccuracy) && (newLocation.verticalAccuracy <= manager.desiredAccuracy))
        [self locationManagerLockedPosition];
}

If a position is locked, this method is called:

- (void)locationManagerLockedPosition
{
    [locationManager stopUpdatingLocation];
    locationManager.delegate = nil;
    [locationManager release], locationManager = nil;
    NSLog (@"add results to view");
}

If it times out, this is the method called:

- (void)locationManagerTimeOut
{
    [locationManager stopUpdatingLocation];
    locationManager.delegate = nil;
    [locationManager release], locationManager = nil;
    NSLog (@"Time out!");
}

Problem is, in either case (time out or locked position), I get the NSLog output in the console and then 2 secs later the app crashes??

Interesting thing is, if I comment out my [locationManager release]... line, everything works fine but WHY? Also if I move the [locationManager release] to my dealloc method, no crashes either!

Am I missing something basic here?

Thanks!

Rog

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:43:14+00:00Added an answer on May 20, 2026 at 6:43 pm

    I had the same issue and there’s probably some problem in the depths of CLLocationManager. Fixed by doing:

    [locationManager stopUpdatingLocation];
    [self performSelector:@selector(discardLocationManager) onThread:[NSThread currentThread] withObject:nil waitUntilDone:NO];
    

    and in discardLocationManager do:

    - (void) discardLocationManager
    {
    
      locationManager.delegate = nil;
      [locationManager release];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question might make one smile, really, HDD space is as cheap as dirt
This question might belong on one of the other trilogies, but it sorta seemed
This might seem like a stupid question I admit. But I'm in a small
This might be one of those huh, why? questions, but I figured it would
This might seem like a silly question, but after asking some questions on stackoverflow
This might be one of those questions that are difficult to answer, but here
This might be a 2 part question. First one is what am I doing
This might be a silly question, but still I am going ahead and asking
This might look like a silly question to some, but handling the different types
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.