美文网首页
随机字母和数字

随机字母和数字

作者: 见路_不走 | 来源:发表于2022-05-10 10:33 被阅读0次

//返回16位大小写字母和数字

+(NSString*)return16LetterAndNumber{//定义一个包含数字,大小写字母的字符串NSString*strAll=@"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//定义一个结果NSString*result=[[NSMutableString alloc]initWithCapacity:16];for(inti=0;i<16;i++){//获取随机数NSInteger index=arc4random()%(strAll.length-1);chartempStr=[strAll characterAtIndex:index];result=(NSMutableString*)[result stringByAppendingString:[NSString stringWithFormat:@"%c",tempStr]];}returnresult;}

相关文章

网友评论

      本文标题:随机字母和数字

      本文链接:https://www.haomeiwen.com/subject/hgklurtx.html