views:

35

answers:

1

Sorry guys, I'm a noob. I know that some languages support type casting, but when I tried to do that here it failed, miserably. I've got an UITextField with number only pad, so I'm only getting numbers, and I need the output from that in my int, diff. Here's what I tried:

NSString *outputNumber = [NSString stringWithFormat:@"%d", [textBox.text]]; 
diff = [outputNumber intValue]; //Not so much

What happens is my diff goes to some incredibly high number instead of the single digets I tested with. Any help I could get is great. Thanks :)

+1  A: 

Why are you using [ ] around textBox.text? And you dont need temporary outputNumber string .

Try this :

diff = [textBox.text intValue];
taskinoor
It seems so simple now! Thanks!P.S. I actually had [textBox text] but I copied it down wrong. I guess I like the nesting better than dot syntax :|
SeniorShizzle