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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:24:50+00:00 2026-05-25T23:24:50+00:00

I was wondering how, in objective c, one would go about making a unit

  • 0

I was wondering how, in objective c, one would go about making a unit converter, in particular one specific point: would you need a new block of code for each unit to be converted to every other unit. e.g.

meters – feet
meters – centimeters
meters – inches

etc then have a new code to convert feet to each of the units, then one for inches to each, another for centimetres to each unit etc, or is there some easier way?

Thanks

  • 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-25T23:24:51+00:00Added an answer on May 25, 2026 at 11:24 pm

    In general all units conversions are of the same form:

    valueInUnit1 = A * valueInUnit2 + B
    

    B often even being zero (meters to feets, inches to meters, etc) — and being non-zero only for a some cases (like converting temperature from Kelvins to Celcius)

    What you only need is to keep a list of the values of A and B for each pair of units to convert one unit to another.

    Note that you can even keep only main values (from metric system units to other units for example) and deduce the others, as from the formula above you can obviously conclude the reverse

    valueInUnit2 = (valueInUnit1 - B) / A = (1/A) * valueInUnit1 + (-B/A)
    

    So once you have the list of values A and B for every pair of units you want to convert from and to, you will only have one method to convert them all.

    You can store the list of values A and B whereever you want, in a dedicated PLIST file, in a sqlite3 database, in CoreData, … (for your case using a PLIST file will probably be much more easier. e.g. a NSDictionary whose keys are the name of the origin unit, and values are themselves NSDictionaries whose keys are destination units and values are the A and B pairs… — that’s just a suggestion, not the only solution)

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

Sidebar

Related Questions

I am wondering how one is supposed to format Objective C code using the
Ok, so I have the code below (Objective-C FYI) and I was wondering if
In several pieces of sample objective-c code I've seen people create new objects like
I was wondering if there is any sample code out there for objective-C for
I am new to Objective C. On one of the developers documentation, I found
I'm still very new to Objective C, and I was wondering something regarding viewDidDisappear.
I'm brand new to Objective-C. Right now, I'm about to C-based calls (open()) and
hopefully this is an easy one. I'm coding in objective-c and i'm wondering if
I am a newbie in Objective C and I was wondering what is the
I've been wondering if there's a way to parse XML in Objective C 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.