Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 25th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. iPhone - Easiest way to fill an NSMutableArray with randoms ints 0 to 3
  2. #include <stdlib.h>
  3.  
  4. ....
  5.  
  6.     NSMutableArray *array = [NSMutableArray arrayWithCapacity:100];
  7.     for (int i = 0; i < 100; i++) {
  8.         [array addObject:[NSNumber numberWithInt:arc4random() & 3]];
  9.     }