I have a textView (tF1) that will be supplied with a numeric value by the user. I need to assign that to number to the int (n).
This is what I came up with:
#import "blabla.h"
int n;
....
[tF1 resignFirstResponder];
n = (int)[tF1 text];
NSLog(@"n is, %d",n);
My problem is that the int value comes out to be a vary large number, like 82296768, for a textview value of 4.
Any and all help would be greatly appreciated! 🙂
SOLVED
changed line,
n = (int)[tF1 text];
to,
n = [[tF1 text] initValue];
NSStringhas a methodintValuethat you should be using:From the documentation for NSString, the other numeric values you can retrieve are:
To invert this process, that is to add a numeric value as a string, you can use the
NSStringmethod-stringWithFormat:, e.g.