Passing a variable to a function

I don’t know if I am putting this question in the right place. I am not a developer but am coding in swift / SwiftUI more as a hobby, on an iPad using Swift Playgrounds.

I am coding a basic drum machine and trying to get start stop buttons functioning.

My loops are in functions. I have a start and stop button. The start button runs the drum loops. The drum loops are infinite so when I want to stop I want to pass a Boolean (true/false) variable from the stop button to interact with the while loop in the function. However once I have tapped the start button and the loop starts running, the stop button is unavaillable - it can’t be tapped. The start button has a pressed in appearance and also can’t be tapped.

if any one wanted to look at the code I could paste it here, or an abbreviated version to show the relevant part of my code.

I'm not sure if I can help you or not, but showing your code would make your post more appealing and you would get more chance to get better replies sooner. Unfortunately, editing feature is strongly restricted in the dev forums and you may need to use answers to show additional info.

Thanks I will repost with the code.

The new thread is here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Passing a variable to a function
 
 
Q