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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:05:15+00:00 2026-05-22T13:05:15+00:00

I am trying to implement the code snippet below. However I am unable to

  • 0

I am trying to implement the code snippet below. However I am unable to get my expected results. For example if my disanceFromLoc = 0.16, I am still getting my output as 0.16 km.

Is there something wrong with the way I am comparing the value? object is of ‘NSNumber’ class (defined it as double in core data)

if ([object.distanceFromLoc doubleValue] < 0)
    {
        cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"Approx. Distance: %0.2f m", [object.distanceFromLoc doubleValue]*1000];
    }
    else 
    {
        cell.detailTextLabel.text = [[NSString alloc] initWithFormat:@"Approx. Distance: %0.2f km", [object.distanceFromLoc doubleValue]];
    }

Thanks!

Zhen Hoe

  • 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-22T13:05:16+00:00Added an answer on May 22, 2026 at 1:05 pm

    I believe you mean to compare to one, not zero.

    As it stands, you’re checking if your distanceFromLoc is negative, which (presumably) never happens with a regular distance. Instead, you should be checking if you’re closer than 1km (i.e. < 1), at which point you can multiply by 1000 and convert to meters.

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

Sidebar

Related Questions

I am trying to implement Bidirectional Mapping with Fluent NHibernate Mapping. Code snippet from
I've been trying to implement unit testing and currently have some code that does
I'm trying to implement http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master into my code. I'm following the Demo provided and
I'm kind of like stuck trying to implement YUI autocomplete textbox. here's the code:
While trying to implement an MVC file upload example on Scott Hanselman's blog. I
I'm trying to implement this code to have different files to load for german,
I'm trying to implement some code to import user's data from another service via
Regarding the following code - I'm trying to get it throw and exception if
I have the following code snippet of a small Thread class I am trying
All I am currently trying implement something along the lines of dim l_stuff as

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.