i have a simple UIButton that, once clicked, plays a 1 second sound. i want to be able to click that button really fast and produce that sound as many times as i humanly can.
i currently have this up and running by including the and maybe that is where the culprit is… also, i am digging into apple’s references and cannot find the info for how quick is a UIButton to respond to each event and how, if at all, i can control and manipulate this value.
should i switch to a different audio framework like the “audio toolbox” or is there a way for me to speed things up, or perhaps instruct a button to accept a 2nd and 3rd press while the action of the first press is still underway.
cheers!
~nir.
Create a method to play the sound separate from the button handler method. Let’s say you call it
playSound. In your button handler, execute that method in the background with:That does incur additional overhead to spawn off a thread before it can play the sound. If you want to speed it up a bit more, create a pool of worker threads and use:
To create the pool of worker threads:
(This code is untested and may require some debugging, but it should get you going in the right direction.)