Hello,
I have an Cocoa touch application I am trying to write and I thought that I would use a separate thread for part of it but after reading the Thread Programming Guide and thinking through it I am confused.
My program needs to play a sound and then wait for a user to respond with a certain action(key press or sound). I will make a determination on what to do next based on their response or lack of response. I need to give them a certain amount of time to react(~5sec) before I play the next sound. I will be going through a series of these iterations and then the series will be done.
I am confused by this because my threads in the past never needed to wait for anything except a variable to be set or function to return before they could continue making decisions in sequence.
I can play sounds and add a timer to the runloop to listen for a sound but how to order a whole sequence of play sound-wait for sound to finish-determine user response-play next sound is not clicking for me. It doesn't make sense because when I add a timer to the loop, it immediately would continue to the next instruction. I basically need to block or something until an answer from my method. But when you use a timer you don't return a value to the point where you called the function, right? Anyway, I know that I am missing something fundamental here and I was hoping someone more knowledgeable than myself could help me out.
Thanks for any help!
I have an Cocoa touch application I am trying to write and I thought that I would use a separate thread for part of it but after reading the Thread Programming Guide and thinking through it I am confused.
My program needs to play a sound and then wait for a user to respond with a certain action(key press or sound). I will make a determination on what to do next based on their response or lack of response. I need to give them a certain amount of time to react(~5sec) before I play the next sound. I will be going through a series of these iterations and then the series will be done.
I am confused by this because my threads in the past never needed to wait for anything except a variable to be set or function to return before they could continue making decisions in sequence.
I can play sounds and add a timer to the runloop to listen for a sound but how to order a whole sequence of play sound-wait for sound to finish-determine user response-play next sound is not clicking for me. It doesn't make sense because when I add a timer to the loop, it immediately would continue to the next instruction. I basically need to block or something until an answer from my method. But when you use a timer you don't return a value to the point where you called the function, right? Anyway, I know that I am missing something fundamental here and I was hoping someone more knowledgeable than myself could help me out.
Thanks for any help!