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 3609140
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:35:21+00:00 2026-05-18T21:35:21+00:00

I will try to make myself as clear as possible. Let start from the

  • 0

I will try to make myself as clear as possible. Let start from the beginning. I have an application with a tableview that contains a list of places with distances from myLocation. Now everytime I get an update in the gps location I run the following code

- (void)locationUpdate:(CLLocation *)location {
 myLocation = location;
 for (Trek * trek in list) {
  CLLocation *loc = [[CLLocation alloc] initWithLatitude:[trek latitude_start]             longitude:[trek longitude_start]];
  double dis = [locationManager getDistance: loc];
  [trek setDistance:dis];
  [trek setDistanceUnit];
  [loc release];
 }

 [self.tableView reloadData];
}

Now this piece of code [trek setDistanceUnit]; calls

-(void) setDistanceUnit {

 if (self.distance < 1000.0) 
  self.distanceString = [NSString stringWithFormat:@"%.0lf m", self.distance];
}

Now if I use only distanceString the application crash. Now I think it may have something to do with the fact that those updates may run concurrently (in parallel) to the access required by the view to draw the cells. Anyone has any idea? I can post more code if helpful, I just didn’t want to post too much to make this post too long.

I tried to search everywhere but I could not found anything so far.

Thanks in advance,
Umberto

PS Now the application is working but I would like to understand what is going on.

  • 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-18T21:35:21+00:00Added an answer on May 18, 2026 at 9:35 pm

    If your distanceString is a retain property, assigning it without self sets it up for a crash because you bypass the setter, and assign the string without retaining it. So when the string gets deallocated on being sent to the autorelease pool, your app crashes.

    By synthesizing the accessors using @synthesize and using the dot notation (or setDistanceString:), the object will retain the string for you so that it always has a pointer to it for itself (until it’s released).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll try to make myself clear with an example: Imagine an admin page to
I'm fairly new to C# but I will try to make this quick! ;)
I am working on an algorithm that will try to pick out, given an
I'm try to develop a regex that will be used in a C# program..
Let me start off by saying that I am very new to WPF and
This might be a little hard to explain, but I will try. I want
I am about to try and automate a daily build, which will involve database
Will I have to pay again? I have about 9 months left before renewal
First off, let me say that this is not homework (I am an A-Level
In terms of expansion of my knowledge, I would like to try to make

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.