生成隨機九位數

- (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.

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章