with this, the buttons are able to randomize and highlight and unhighlight by its own, but for now, it gave me randomize in a fast way. Can I know how to control the randomize speed, as well as to limit how many times it is to be randomize?

1) just doing int d = (arc4random()% count) is sufficient for randomization, in doing so you would check 0-count.
2) code isn't very robust. it will lead to unpredictable results. If you truly only have 4 options, then: int d = (arc4random()% 4) and then use a switch, 0-3.

now all these are asides from your question: what do you mean by "randomize speed"?

(Dec 12, 2010 06:40 AM)backslash Wrote: That's because you are telling them all to highlight after a delay of 2 seconds. To make them flash at different times you will need to change the delay. Try using i as the delay time.

it is still the same as i is still considered an integer.
i tried using NSTimer to slow down the random speed but it still went random highlighting of several buttons at a time after 10-13 "self-generated" highlights.

(Dec 13, 2010 12:00 AM)soulesstps Wrote: it is still the same as i is still considered an integer.

OK, use (float)i.
My point is that if you give the same delay to all the buttons, they will all flash at the same time (after the same delay). You need to give a different delay time to each button. I suggested using i because it changes as you iterate through your buttons. performSelector:withObject:afterDelay doesn't block the thread, so you are sending these messages to all the buttons at almost exactly the same time.
I've also just noticed that, for the same reason, you are unhighlighting all your buttons 1.99 seconds before you highlight them, which will presumably make them all light up and stay lit. The delay for the "turn back off" function needs to be "delay until it lights up"+"time it is to stay lit for".