XCode (Swift) - Prevent a function from running more than once (Need screenshare help)
Budget: $10 – $30 USD
Hi there. First, I need someone who can screenshare with me real quick to fix this because I can't share the project and it's on XCode 12.5. I have a project in XCode and one of my most important functions is running multiple times. I need to make it so it only runs once. I think I can set a bool at the beginning of the function or outside of it, like
isRunning = true
then maybe add DispatchQueue.main.asyncAfter(deadline : .now() + 10) to maybe prevent it from running again for 10 seconds - but I'm not sure if it'll work and I am correct. Also, does that mean my function WILL run again in 10 seconds (if I don't want it to)?
I just want to make the function only execute one time. It's an e-commerce function, so it's causing a payment to be taken multiple times!
I need/want to fix this quick, so I can get a fixed build uploaded to TestFlight.
Thanks!!
isRunning = true
then maybe add DispatchQueue.main.asyncAfter(deadline : .now() + 10) to maybe prevent it from running again for 10 seconds - but I'm not sure if it'll work and I am correct. Also, does that mean my function WILL run again in 10 seconds (if I don't want it to)?
I just want to make the function only execute one time. It's an e-commerce function, so it's causing a payment to be taken multiple times!
I need/want to fix this quick, so I can get a fixed build uploaded to TestFlight.
Thanks!!