iPhone OS - Vibration - Simple Version

/ Published in: Objective C
Save to your folder(s)

Creating a vibration is simple as pie - simpler in fact. It just requires one line of code; two if you add the import line. But as simple as a one-liner is it is better to make it into a function. So here is the one liner, followed by the function. Cheers!

Copy this code and paste it in your HTML
  1. // NOTE: You need to import the AudioToolbox for access to the vibrate
  2. #import <AudioToolbox/AudioToolbox.h>
  4. // The one-liner:
  5. AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
  7. // The function:
  8. - (void)vibrate {
  9. AudioServicesPlaySystemSound (kSystemSoundID_Vibrate);
  10. }
  12. // The call from within another method in the same class:
  13. - (void)myMethod {
  14. [self vibrate];
  15. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.