0

User will play a wave file by holding a key down. But once he lifts his finger off the key, it will stop playing the wave file.

The only way I can think of doing this is using a thread:

  1. The only way I can think of doing this successfully is by placing the playing of a wave file into a thread.
  2. The thread starts operation(wave file) when the key is pressed.
  3. The operation(wave file) is stopped by killing the thread.

This will be repeated many times. And I don't know if the user killing threads over and over again will kill the iPhone? Is there a better way?

jdl
  • 6,151
  • 19
  • 83
  • 132
  • 1
    Just a quick note, repetitively opening and killing threads won't harm the processor in that way. But make sure you do good clean up so that your memory wont get filled. Also you can pause and notify threads than killing. One answer is here http://stackoverflow.com/questions/1557070/how-to-pause-an-nsthread-until-notified – Sukitha Udugamasooriya Jun 24 '15 at 01:57
  • 1
    Check this answer in stackoverflow. http://stackoverflow.com/questions/11376269/looping-audio-in-xcode – Sukitha Udugamasooriya Jun 24 '15 at 02:01

1 Answers1

1

Threads are made to be created and killed. There is no way to physically break your device like this.
Just make sure to keep things clean and monitor your memory usage to detect any leak or forgotten ressources.

Quentin Hayot
  • 7,786
  • 6
  • 45
  • 62