Skip to content

Instantly share code, notes, and snippets.

@irpainel-zz
Created February 25, 2016 14:37
Show Gist options
  • Save irpainel-zz/831472552f143589cc43 to your computer and use it in GitHub Desktop.
Save irpainel-zz/831472552f143589cc43 to your computer and use it in GitHub Desktop.
Guide Utils
+(BOOL)randomBool {
int tmp = (arc4random() % 30)+1;
if(tmp % 5 == 0)
return YES;
return NO;
}
+(int)randomNumberInRangeMin:(int)min max:(int)max {
return rand() % (max - min) + min;
}
+(NSString *)randomPlaceholderUrlWithWidth:(NSInteger)width height:(NSInteger)height {
unsigned int baseInt = arc4random() % 0xFFFFFF;
NSString *backgroundHex = [NSString stringWithFormat:@"%06X", baseInt];
NSString *textHex = @"ffffff";
return [NSString stringWithFormat:@"https://placehold.it/%dx%d/%@/%@",(int)width, (int)height, backgroundHex, textHex];
}
+(NSString *)randomPlaceholderImageUrlWithWidth:(NSUInteger)width height:(NSInteger)height {
return [NSString stringWithFormat:@"https://unsplash.it/%d/%d/?random",(int)width, (int)height];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment