Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if random number is initialized to 0, it will be reset on next run() #6

Open
jauboux opened this issue Sep 8, 2016 · 0 comments
Open

Comments

@jauboux
Copy link

jauboux commented Sep 8, 2016

generateRandomNumber() return a number in [0,99]
stored integer is tested against 0 so there is 1 chance out of 100 that number will change:

    public func ab_getRandomNumberWithKey(key: String) -> Int {
        var randomNumber = integerForKey(key)
        if randomNumber == 0 {
            randomNumber = generateRandomNumber()
            setInteger(randomNumber, forKey: key)
        }
        return randomNumber
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant