Created
June 28, 2013 14:30
-
-
Save jdriselvato/5885098 to your computer and use it in GitHub Desktop.
A simple and efficient method to generate a NSString of random characters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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