Skip to content

Instantly share code, notes, and snippets.

@jdriselvato
Created June 28, 2013 14:30
Show Gist options
  • Save jdriselvato/5885098 to your computer and use it in GitHub Desktop.
Save jdriselvato/5885098 to your computer and use it in GitHub Desktop.
A simple and efficient method to generate a NSString of random characters.
-(NSString*)generateRandomString:(int)num {
NSMutableString* string = [NSMutableString stringWithCapacity:num];
for (int i = 0; i < num; i++) {
[string appendFormat:@"%C", (unichar)('a' + arc4random_uniform(25))];
}
return string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment