title: Problems with AVAudioPlayer
body: <p>I'm new to the iPhone-Development. </p>
  
  <p>I want to play a Sound when an UIButton is tapped. I tried the following:</p>
  
  <p>ViewController.h:</p>
  
  <pre><code>@interface JahrenzeitenViewController : UIViewController &lt;AVAudioPlayerDelegate&gt; {
  
      UIButton *button_PlaySound;
      AVAudioPlayer *audioPlayer;
  }
  
  @property (nonatomic, retain) IBOutlet UIButton *button_PlaySound;
  </code></pre>
  
  <p>ViewController.m</p>
  
  <pre><code>- (IBAction)playSound {
  
      //[audioPlayer release];
      //audioPlayer = nil;
  
      NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"wav"];
      NSURL *audioFileURL = [NSURL fileURLWithPath:audioFilePath];
      NSError *error = nil;
      audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:&amp;error];
      [audioPlayer setDelegate:self];
      [audioPlayer prepareToPlay];
      [audioPlayer play];
      if (audioPlayer == nil) 
          NSLog(@"Error playing sound. %@", [error description]);
      else
          [audioPlayer play];
  </code></pre>
  
  <p>If I try to run the App, I get the following error:</p>
  
  <blockquote>
    <p>Undefined symbols for architecture i386:
      "_OBJC_CLASS_$_AVAudioPlayer", referenced from:
          objc-class-ref in JahrenzeitenViewController.o
    ld: symbol(s) not found for architecture i386
    collect2: ld returned 1 exit status</p>
  </blockquote>
  
  <p>I also tried to change the Line</p>
  
  <pre><code>audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:&amp;error];
  </code></pre>
  
  <p>to</p>
  
  <pre><code>audioPlayer = [audioPlayer initWithContentsOfURL:audioFileURL error:&amp;error];
  </code></pre>
  
  <p>Then I don't get the error above, but its still not playing and i get the DebugMessage from my NSLog in the "playSound"-Method:</p>
  
  <blockquote>
    <p>Error playing sound. (NULL)</p>
  </blockquote>
  
  <p>I hope you can help me. Thank you in advance :)</p>