I am making a morse code app and I want to play the sounds one after another but I can't seem to get it to work. They are all playing at the same time so I can only here the last one. This is what I have so far.
This is my delay function.
func delay(delay:Double, closure:()->()) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,Int64(delay * Double(NSEC_PER_SEC))),dispatch_get_main_queue(), closure)
}
This is my iteration loop
for i in morseArray
{
println("delayTime: \(delayTime)")
if i == "."
{
delay(delayTime++, closure: { () -> () in
self.dotSound.play()
})
}
else if i == "-"
{
delay(delayTime++, closure: { () -> () in
self.dashSound.play()
})
}
}