objective c - iPhone - Easiest way to fill an NSMutableArray with randoms ints 0 to 3 -


I want to fill a NSMutableArray with 100 random instances of 0 to 3. I am still struggling with objective- C.

Easiest way?

  #include & lt; Stdlib.h & gt; .... NSMutableArray * array = [ability with NSMutableArray array: 100]; For (int i = 0; i & lt; 100; i ++) {[array addObject: [NSNumber numberAttro: arc4random () & amp; 3]]; }    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -