Extract Integer from UITextField?

Discussion in 'iOS Programming' started by parkov, Aug 8, 2008.

  1. parkov macrumors newbie

    Joined:
    Aug 29, 2005
    #1
    Newbie question here.

    How do I extract an int value from a UITextField (textKey)? I have the following:

    NSInteger inputKey = textKey.text;​

    Which gives me this warning:

    warning: initialization makes integer from pointer without a cast​

    Thanks!
     
  2. sfwalter macrumors 68000

    sfwalter

    Joined:
    Jan 6, 2004
    Location:
    Dallas Texas
    #2
    You can't take an object and assign it to a primitive. NSInteger is really just a typedef of int. You can do this:

    NSInteger theInteger = [textKey.text intValue];
     
  3. parkov thread starter macrumors newbie

    Joined:
    Aug 29, 2005
    #3
    Thanks. Can you go in the other direction, or do you have to use methods for those as well? For example:

    creating an NSMutableArray from ints

    creating an NSString from chars
     

Share This Page