retrieving integer value from the UITextField into a NSInteger variable

SST picture SST · May 20, 2009 · Viewed 8.6k times · Source
UITextField *textField;
NSInteger intRollNumber;

I want to take rollNumber as input from the textField and store the value into intRollNumber .

How i do that? Because I am unable to convert the string into integer.

Answer

dermdaly picture dermdaly · May 20, 2009

Like this?

NSString *str = [textField text]
int RollNumber = [str intValue];