Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #180 from marlonandrade/master

Safe returning nil on randomObject on NSArray category
  • Loading branch information...
commit 7e6cfe595be1586c53be8c4c8e0b2710318cc6fd 2 parents 47e6ff7 + 23423e2
@soffes authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 SSToolkit/NSArray+SSToolkitAdditions.m
View
4 SSToolkit/NSArray+SSToolkitAdditions.m
@@ -26,6 +26,10 @@ - (id)firstObject {
- (id)randomObject {
+ if ([self count] == 0) {
+ return nil;
+ }
+
return [self objectAtIndex:arc4random_uniform([self count])];
}
Please sign in to comment.
Something went wrong with that request. Please try again.