- (NSString*) getRandomEmail
{
NSString *answer = [NSString stringWithFormat:@"%@@%@.com", [self getRandomString], [self getRandomString]];
return answer;
}
- (NSString*) getRandomString
{
NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
int len = [self getRandomIntBetweenBottomInt:1 andTopInt:7];
NSMutableString *randomString = [NSMutableString stringWithCapacity: len];
for (int i=0; i < len; i++) {
[randomString appendFormat: @"%C", [letters characterAtIndex: arc4random() % [letters length]]];
}
return randomString;
}
- (int) getRandomIntBetweenBottomInt:(int)bottom andTopInt:(int)top
{
int randomNumber = (arc4random() % top) + bottom;
return randomNumber;
}
and this is the result: