Yet another noob...

Discussion in 'iOS Programming' started by jessejohnson147, Jun 5, 2009.

  1. jessejohnson147 macrumors newbie

    Jun 5, 2009
    What I am trying to achieve is to have a bg image that will randomize when the user clicks the randomize button, but finding a good randomize code that I could use to learn has been hard to come by. Does anyone know any good resources for a random generator code?

  2. BlackWolf macrumors regular

    Apr 9, 2009
    it really all depends how you define "good".
    all the numbers you generate will be pseudo-random. getting real random numbers isn't possible with a normal computer as far as I know.

    I found the following to be working ... ok ... for me. If you don't need it for some security stuff it should do the trick:
    int randomNumber = arc4random()%maximumNumber;
    whereas maximum number is ... well ... the maximum you want your random number to be. if you don't need a max just ommit that part and you should get something between 0 and INT_MAX

Share This Page