Generating random numbers is easy. If you want random numbers that are new each time use:
arc4random();
to set a start and range:
#define RANDOM_START 10
#define RANDOM_RANGE 20
#define randomNumber() ((arc4random() % RANDOM_RANGE) + RANDOM_START)
this will give random numbers from 10 through 29. 20 numbers starting at 10.
OR
#define randomNumber(s, r) (arc4random() % (r) +(s))
Note that a range of 5 will give 5 numbers, not 0 - 5 but 0 - 4
Code examples for doing simple and interesting things on the iPhone and iPod touch.
Monday, October 19, 2009
Good Vibrations
Add vibration with this easy 'C' call:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Subscribe to:
Comments (Atom)