Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dylan552

macrumors newbie
Original poster
Sep 1, 2010
11
0
I need a segment of code that takes a string from number.text and makes it in to a double. Which i can then use to make a calculation. I have tried many other soultion i found on tht site but all had errors or just didnt work.
 
I have always just used:

[textField.text intValue];

or

[textField.text doubleValue];

The text property returns an NSString. If you look up NSString in the documentation, you will see in the long list of methods, that there is a section of methods labeled "Getting Numeric Values". The two above methods are there as well as a couple other ones (like boolean, long, etc.).
 
Three simple rules of thumb:
1. Post your code.
2. Describe what you expected to happen.
3. Describe what did happen. Include the actual text of any error messages.

When you leave any of these out, we have to guess.
Guessing is a remarkably bad debugging approach.

A fourth rule:
4. If you didn't write the code yourself, tell us exactly where you copied it from: a book (title & author), a website (give the URL), etc.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.