Posted By

KevinBomberry on 06/24/09


Tagged

Objective-c iphone


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

cgrainger
DASKAjA
mattnews
umang_nine
hERB
davidsi
espinallab
vmonje
bornykd
clementcollier
Tintenklecks
AndreyZarembo


iPhone OS - Vibration - Simple Version


 / Published in: Objective C
 

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!

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

Report this snippet  

You need to login to post a comment.