Reputation: 164
I use this code inside my motionBegan function. And when i shake my device it vibrates. Is there a way to add a delay so vibration begins after 1 second later for example?
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
Upvotes: 1
Views: 950
Reputation: 17724
For Swift 3 and up, use a DispatchQueue
:
DispatchQueue.main.asyncAfter(.now() + 1.0) {
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
}
Upvotes: 3
Reputation: 535402
Use GCD dispatch_after
. (The easiest way is with my delay
function, shown here: https://stackoverflow.com/a/24318861/341994.)
Upvotes: 3