bogdan barbulescu bogdan barbulescu - 7 months ago 49
Swift Question

Generate number of 9 digits in Swift

How can I generate a 9 digits number in Swift.
I have tried random() function, but the size of the generated number is different every time the function is called.
I have also tried this code enter link description here , but it is deprecated.

import Foundation

func random9DigitString() -> String {
    let min: UInt32 = 100_000_000
    let max: UInt32 = 999_999_999
    let i = min + arc4random_uniform(max - min + 1)
    return String(i)