title: Obj-C ios AudioToolkit not playing sound
body: <p>When I hard-code the sound name into there, it works, but when I use a random generator to create the string, it doesn't. BTW: This is in Xcode 4.3 and iPhone 5.1 simulator.</p>
  
  <hr>
  
  <pre><code>int rand = round(arc4random_uniform(3));
  char buf[100];
  sprintf(buf,"Sound%d.aifc",rand);
  //get the filename of the sound file
  NSString *fp=[NSString stringWithUTF8String:buf];
  NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], fp];
  //declare a system sound
  SystemSoundID soundID;
  
  //get a path for the sound file
  NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
  
  //create the sound id
  AudioServicesCreateSystemSoundID((CFURLRef)filePath, &amp;soundID);
  
  //play the sound
  AudioServicesPlaySystemSound(soundID);
  </code></pre>