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

parkov

macrumors newbie
Original poster
Aug 29, 2005
24
19
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!
 
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!

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];
 
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];

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.