To play a sound on your iPhone, first of all, you shall add the Audio the Audio Toolbox framework into your frameworks group in XCode. Then, at the beginning of your view controller add the following line:

#import <AudioToolbox/AudioToolbox.h>


Now insert the .wav drag and drop your wav file into the resource folder of your project into xcode window.

 

 

Last insert the following code where you want to play your .wav file:


//Get the filename of the sound file:

                NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/filename.wav"];

                SystemSoundID soundID;

                NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];

                //Use audio sevices to create the sound

                AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);

                //Use audio services to play the sound

                AudioServicesPlaySystemSound(soundID); 


To play a vibration read the related post.

 

 

Gg1