title: AVFoundation - iOS can't hear sound
body: <p>I'm trying to play a mp3 file using AVFoundation framework. It can't detect the file and has the following error: </p>
  
  <pre><code>     Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
  </code></pre>
  
  <p>Code implemented:</p>
  
  <pre><code>NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"];
  NSLog(@"directory %@",path);
  AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
  theAudio.delegate = self;
  [theAudio play];
  </code></pre>
  
  <p>When I change the pathForResource:@"sound" to pathForResource:@"sound " (the space ) it can detect the file but no sound heard. I have declared the AVdelegate in the .h file too. Anyone knows whats the problem?</p>