title: code to play sound programmatically using a button on the iphone
body: <p>I am trying to figure out how to hook up a button to play a sound programmatically without using IB.  I have the code to play the sound, but have no way of hooking the button up to play the sound? any help?</p>
  
  <p>here is my code that I'm using:</p>
  
  <pre><code>     - (void)playSound
      {
          NSString *path = [[NSBundle mainBundle] pathForResource:@"boing_1" ofType:@"wav"];
          AVAudioPlayer* myAudio = [[AVAudioPlayer alloc] 
                   initWithContentsOfURL:[NSURL fileURLWithPath:path error:NULL]];
          myAudio.delegate = self;
          myAudio.volume = 2.0;
          myAudio.numberOfLoops = 1;
          [myAudio play];
      }
  </code></pre>