Here's some code that it intended to make the phone vibrate (async), await the completion of this task, and then make it vibrate again immediately after:
func vibrate() {
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
AudioServicesAddSystemSoundCompletion(SystemSoundID(kSystemSoundID_Vibrate), nil, nil, { (soundId, clientData) -> Void in
self.vibrate()
}, nil)
}
Xcode gives the following error:
A C function pointer cannot be formed from a closure that captures context
How I can recurse from inside of this async function?