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

    #1
    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

    dejo

    Staff Member

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

Share This Page