Ответ 1
NSString *min = myMinTextField.text; //Get the current text from your minimum and maximum textfields.
NSString *max = myMaxTextField.text;
int randNum = rand() % ([max intValue] - [min intValue]) + [min intValue]; //create the random number.
NSString *num = [NSString stringWithFormat:@"%d", randNum]; //Make the number into a string.
[myLabel setText:num]; // Give your label the value of the string that contains the number.
Update:
Похоже, что лучше использовать arc4random
, а не rand
, вы можете увидеть больше об этом здесь. Просто замените все rand
на arc4random