I have a routine to randomly pick an item from a NSArray using
random() % 9
where 9 is the number of items in the NSArray. The problem I'm seeing is that every time I start my application, I'm getting the exact same random numbers being generated. This only happens when I exit the application and than restart it. I was expecting to see a different pattern each time I start the app. Is there a way to randomize the random function?
-- Thanks
random() % 9
where 9 is the number of items in the NSArray. The problem I'm seeing is that every time I start my application, I'm getting the exact same random numbers being generated. This only happens when I exit the application and than restart it. I was expecting to see a different pattern each time I start the app. Is there a way to randomize the random function?
Code:
NSString strTemp = [[ NSArray arrayWithObjects: @"a.png", @"b.png", @"c.png",
@"d.png", @"e.png", @"f.png", @"h.png",@"i.png",
@"j.png",nil] objectAtIndex: (random() % 9)];
-- Thanks