生成随机九位数

- (NSString *)getRandomMappingId {

    NSString *min = @"000000000"; //Get the current text from your minimum and maximum textfields.

    NSString *max = @"999999999";

    srand([[NSDate date] timeIntervalSince1970]);

    int randNum = rand() % ([max intValue] - [min intValue]) + [min intValue]; //create the random number.

    

    return [NSString stringWithFormat:@"%d", randNum]; //Make the number into a string.

}

你可能感兴趣的:(笔记)