PDA

View Full Version : Random numbers and sliders




iphonedevelop18
Mar 2, 2009, 12:53 PM
How do i generate a random number say 1-100 and make that a variable?

Also i want to know how to take the value of a slider and output that as a label.



dejo
Mar 2, 2009, 01:27 PM
How do i generate a random number say 1-100 and make that a variable?
int randomValue = ( random() % 100 ) + 1;

Also i want to know how to take the value of a slider and output that as a label.
NSString *labelText = [[NSString alloc] initWithFormat:@"%f", slider.value];
label.text = labelText;
[labelText release];