-1

I will explain my project before I get into my question. On the first view you select either UK shoe size (button) or US shoesize (button). then it brings you to another view which has 2 text boxes.(labeled women or mens) If you select men and type a "9" then in the background it does this equation (21.75 + shoeSize) / 3= ans.

It will then take the answer and do this answer / 12 = Feet. Then one the next screen it will have a label that says "how many feet?" then you enter how many feet. In the background it will do this feet * whateverYouPutInBox = steps. Then display the answer on a new screen. I need to know how to do the background equations! (I'm new to iOS programming) this may seem simple to most people. But please help me. If you need anything explained please reply!

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • 3
    Why do you need a background calculation? What have you tried so far? Post the relevant code you need help with. – rmaddy Feb 13 '14 at 20:40
  • 1
    It may seem like a good idea to do background computations from reading other sources, but for simple math and non time-consuming operations like yours, there is absolutely no need to do background computing – Jack Feb 13 '14 at 20:44
  • What do you mean by background equations? Are you referring to multithreading or just what goes on behind the scenes? – 67cherries Feb 13 '14 at 20:47
  • behind the scenes, im doing this for a school project, and im just starting out on learning to code for apple – user3307527 Feb 13 '14 at 22:38
  • 1
    If you're just starting out, asking questions on Stack Overflow is not the place you need to be. You should find a good book or a series of online tutorials. Have a look at [Good resources for learning ObjC](http://stackoverflow.com/questions/1374660/good-resources-for-learning-objective-c?rq=1) The Big Nerd Ranch books are excellent, and lots of people like the Stanford iOS course on iTunes U. Good luck! – jscs Feb 14 '14 at 05:07

1 Answers1

0

Just reverse your equations:

float answer = (21.75 + [shoeSizeTextfield.text floatValue])/3;
float feet = answer/12;
float steps = feet * [numberOfFeetTextField.text floatValue];

And no need to run them in the background since they take a fraction of a second.

But when you say "display on a new screen" what do you mean? You want to transfer the values to another view controller? If so, check out this answer: Passing Data between View Controllers.

Community
  • 1
  • 1
Lyndsey Scott
  • 37,080
  • 10
  • 92
  • 128