I am surprised I can't find this answer but for some reason can't find it for Xcode.
In my app I have an IBAction buttonPressed and it adds coins to my "coins" variable and displays it in a UILabel. I would like to make it so when the user presses the button it does not add the coins or display it in the UILabel for about 30 seconds. Is there a simple way to do this? I'm pretty new, so please explain in simple steps if possible. Thank You :)
It's very easy, just use performSelector:withObject:afterDelay:. You would put it in your IBAction code like this:
-(IBAction)buttonPressed:(UIButton *) sender {
[self performSelector:@selector(addCoins) withObject:nil afterDelay:30];
}
-(void)addCoins {
//put whatever code you want to happen after the 30 seconds
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With