Getting a number from a string

Discussion in 'iOS Programming' started by Duke Leto, Jan 28, 2009.

  1. Duke Leto macrumors regular

    Joined:
    Mar 17, 2008
    #1
    How is it possible to get a number value from a string that the user inputted?
     
  2. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #2
    What do you want to do with that number? I can think of a few ways to grab that value, but they are specific to different situations.
     
  3. Duke Leto thread starter macrumors regular

    Joined:
    Mar 17, 2008
    #3
    Do a calculation and set a UISlider's value to that number.
     
  4. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #4
    Are the inputting the number via a textfield?
     
  5. Duke Leto thread starter macrumors regular

    Joined:
    Mar 17, 2008
  6. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #6
    You can just use

    Code:
    [textField.text integerValue]
    
    to grab the numeral value of the field. No need to pass it to a string.
     
  7. Duke Leto thread starter macrumors regular

    Joined:
    Mar 17, 2008
    #7
    Awesome! Thank you for the help! I as looking at the docs for NSNumberFormatter .. :eek:.
     
  8. Jeremy1026 macrumors 68020

    Jeremy1026

    Joined:
    Nov 3, 2007
    #8
    No problem man.
     

Share This Page