w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how do I make a limit in up counter?

Let's say the you have the value of your counter stored in a variable, say, counterValue.

Every time you add 1 to counterValue, simply check if the new value equals 15, and if it does, reset the value back to 0.

- (void)buttonTapped {
    counterValue++;
    if(counterValue == 15) {
        counterValue = 0;
    }
}

I can't give you a more specific example because you didn't share your current code, so hopefully this is enough to get you started in your own project.


Welcome to Stack Overflow!





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.