title: Playing a sound in on device with Objective C
body: <p>I've looked at a lot of answers on here for this question and can't get any to work.</p>
  
  <p>Here is my issue, I'm trying to play a sound on a button press, here is where the file is located<a href="https://i.stack.imgur.com/j3W2Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j3W2Y.png" alt="File Location"></a></p>
  
  <p>Here is my code</p>
  
  <pre><code>- (void)playSoundWithOfThisFile:(NSString*)fileName {
  
  NSString *soundFilePath = [NSString stringWithFormat:fileName,
                             [[NSBundle mainBundle] resourcePath]];
  NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
  
  AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL
                                                                 error:nil];
  player.numberOfLoops = 1;
  
  [player play];
  </code></pre>
  
  <p>}</p>
  
  <p>When I run through the code the values are as follows</p>
  
  <pre><code>fileName = Mummy.mp3
  
  `soundFilePath = Mummy.mp3`  (I've had it Sounds/Mummy.mp3 and this doesn't work either)
  </code></pre>
  
  <p><code>soundFileURL  = Mummy.mp3</code> -- file:///</p>
  
  <pre><code>player = nil
  </code></pre>
  
  <p>Any help would be greatly appreciated. The error if I catch it is just a generic error with no info</p>