title: How do I get the filesystem path for a resource on iPhone?
body: <p>On the iPhone I need to get the path for the resource. OK, done that, but when it comes to CFURLCreateFromFileSystemRepresentation thing, I just don't know how to solve this. Why does this error occur? Any solution or workaround would be highly appreciated. Thank you in advance.</p>
  
  <p>I have taken a look at the following examples in order to play audio using AudioQueue on the iPhone:
  SpeakHere, AudioQueueTools (from the SimpleSDK directory) and AudioQueueTest. I tried do this and that, trying to put the puzzles together. Right now, I am stuck at this. The program crashed because of the exception thrown from the sndFile above.</p>
  
  <p>I am using AVAudioPlayer to play every sound on my iPhone games. On the real iPhone device, it turned out to be very laggy when a sound is to be played, so I decided I need to use AudioQueue.</p>
  
  <pre><code>- (id) initWithFile: (NSString*) argv{
  
      if (self = [super init]){
          NSString *soundFilePath = [[NSBundle mainBundle]
                                      pathForResource:argv
                                               ofType:@"mp3"];
          int len = [soundFilePath length];
          char* fpath = new char[len];
  
          //this is for changing NSString into char* to match
          //CFURLCreateFromFileSystemRepresentation function's requirement.
          for (int i = 0; i &lt; [soundFilePath length]; i++){
              fpath[i] = [soundFilePath characterAtIndex:i];
          }
  
          CFURLRef sndFile = CFURLCreateFromFileSystemRepresentation
                             (NULL, (const UInt8 *)fpath, strlen(fpath), false);
          if (!sndFile) {
              NSLog(@"sndFile error");
              XThrowIfError (!sndFile, "can't parse file path");
          }
  }
  </code></pre>