Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Replace arc4random() with arc4random_uniform() to improve randomness #134

Merged
merged 1 commit into from

2 participants

@density

Using arc4random() % [self count] to choose an object will generate biased results when the array length is not a power of 2. Switching to arc4random_uniform() fixes this.

@soffes
Owner

Good call!

@soffes soffes merged commit af60a23 into soffes:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 11, 2012
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  SSToolkit/NSArray+SSToolkitAdditions.m
View
2  SSToolkit/NSArray+SSToolkitAdditions.m
@@ -25,7 +25,7 @@ - (id)firstObject {
- (id)randomObject {
- return [self objectAtIndex:arc4random() % [self count]];
+ return [self objectAtIndex:arc4random_uniform([self count])];
}
Something went wrong with that request. Please try again.