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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:00:24+00:00 2026-06-18T01:00:24+00:00

I want to display the distance between a user’s current location and another annotation

  • 0

I want to display the distance between a user’s current location and another annotation (displayed on my MapView) in a label on my custom table cell.

Each cell displays the name of a cafe (nameLabel), and underneath, I want it to display their distance away from each cafe (distanceLabel).

My MapViewController.m uses this code to calculate the distance between a user’s current location and the closest cafes:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    for (MapViewAnnotation *annotation in self.mapView.annotations) {
        CLLocationCoordinate2D coord = [annotation coordinate];
        CLLocation *userLocation = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];
        annotation.distance = [newLocation distanceFromLocation:userLocation];
        CLLocationDistance calculatedDistance = [userLocation distanceFromLocation:userLocation];
        annotation.distance = calculatedDistance;
    }

I’ve already set up my custom cell, I just want to know what I should put into my TableView code (TableViewController.m) in order to display the Calculated Distance inside of my text label (called distanceLabel).

E.g. how do I finish this line?

cell.distanceLabel.text = 

UPDATE

Just tried adding the reference to my TableViewController.h, but xcode keeps throwing me the error “Redefinition of ‘CLLocationDistance’ as different kind of symbol”.

@class CLLocationDistance; 

@property (nonatomic, strong) CLLocationDistance *calculatedDistance; 

UPDATE

.h file

enter image description here

****UPDATE**

**.m file****

enter image description here

  • 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-06-18T01:00:26+00:00Added an answer on June 18, 2026 at 1:00 am

    Make a forward reference for CLLocationDistance calculatedDistance in fx. Your .h . CLLocationDistance is typedef as a double, a prmitive data type, so don’t use a pointer in your forward reference (CLLocationDistance calulatedDistance; or @property CLLocationDistance calulatedDistance;). Then do the following:

     cell.distanceLabel.text = [NSString stringWithFormat:@"%f", calculatedDistance]; 
    

    So infact you dont have to create another/new double and assign it to calculatedDistance. Sorry for any confusion..:)

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

Sidebar

Related Questions

I want to put facility to display distance between two places selected by user.
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I want to display result of this javascript in a label control on my
I want display data of table. And I can't display instead of the fields-id
I want to set a distance of 20px between every single list. HTML: <div
I got the below code from @DanS at this link how-to-display-a-map-still-image-file-with-a-moving-current-location onCurrentPosition(Location current){ double
I want display Google maps in the Android Based on the user edit text
Suppose I want display table: +--------------------------------+ | | | | ---------------------------------- | | |
I am performing distance calculations between addresses. Specifically the distance between a User and
I want display data from database in Listbox...Here is my code, It is not

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.