在代码的日子里希望你我同行!

关于如何用OC代码实现随机生成A-Z的字符串

关于如何用OC代码实现随机生成A-Z的字符串

  • (void)createDataSource {
    //初始化数据源
    NSMutableArray *arra = [[NSMutableArray alloc]init];
    for (int a = 0; a < 100; a++) {
    NSMutableArray *arr = [[NSMutableArray alloc]init];

    for (int i = 'a'; i <= 'z' ; i++) {
    NSMutableArray * small = [[NSMutableArray alloc]init];
    for (int j = 0; j < 100; j++) {
    NSString * string = [NSString stringWithFormat:@"%c%c%c%c",i,arc4random()%26+'A',arc4random()%26+'A',arc4random()%26+'A'];
    NSString *str = [NSString stringWithFormat:@"http://%@.yiem.net",string];
    [small addObject:str];
    }
    [arr addObject:small];
    }
    [arra addObject:arr];
    }
    NSLog(@"%@", arra); }

关于如何用OC代码实现随机生成A-Z的字符串

发表新评论
Title - Artist
0:00