retrieving integer value from the UITextField into a NSInteger variable
问题 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. 回答1: Like this? NSString *str = [textField text] int RollNumber = [str intValue]; 回答2: See the text property and integerValue. 来源: https://stackoverflow.com/questions/886925/retrieving-integer-value-from-the-uitextfield-into-a-nsinteger-variable