//产生length个长度随机字符串
- (NSString *)getRandStringWithLength:(int)length
{
NSString *sourceStr = @"0123456789abcdefghijklmnopqrstuvwxyz";
NSMutableString *resultStr = [[NSMutableString alloc] init];
for (int i = 0; i < length; i++)
{
unsigned index = arc4random() % [sourceStr length];
NSString *oneStr = [sourceStr substringWithRange:NSMakeRange(index, 1)];
[resultStr appendString:oneStr];
}
return resultStr;
}
网友评论