1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Random numbers and sliders

Discussion in 'iPhone/iPad Programming' started by iphonedevelop18, Mar 2, 2009.

  1. macrumors member

    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.
  2. Moderator


    Staff Member

    int randomValue = ( random() % 100 ) + 1;
    NSString *labelText = [[NSString alloc] initWithFormat:@"%f", slider.value];
    label.text = labelText;
    [labelText release];

Share This Page