title: AVAsset not recognising NSURL - Crashing - iOS
body: <p>I am making an iOS app. One of its features is that it can save record and save audio files.</p>
  
  <p>In order to save the URL's of the recorded audio files, I storing them in NSUserDefaults as filePaths like so:</p>
  
  <blockquote>
    <p>file:///var/mobile/Containers/Data/Application/17F8E799-D7E1-4B3C-9DFE-7BA48E346314/Documents/recordName.aif</p>
  </blockquote>
  
  <p>I am using a library called "FVSoundWaveDemo" to try and display a sound wave for the recorded file. But I have a problem with URL's... </p>
  
  <p>The example in "FVSoundWaveDemo" loads a locally imported file like so:</p>
  
  <pre><code>NSString* filename = [NSString stringWithFormat:@"song1.m4a"];
  NSURL* url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:filename ofType:nil]];
  _soundWaveView.soundURL = url;
  </code></pre>
  
  <p>You see the bit with "song1.m4a", well I want to replace that and get the app to use a filePath URL instead. Like the filePath URL I displayed above in my question.</p>
  
  <p>I have tried all sort of things like trying to "convert" the filePath into a normal URL and trying to use AVAssets and so on. But everything I try just comes up with this error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'</p>
  </blockquote>
  
  <p>And this is because the library I am using, uses AVAssets like so:</p>
  
  <pre><code>AVAssetReader* reader = [[AVAssetReader alloc] initWithAsset:songAsset error:&amp;error];
  
  AVAssetTrack* songTrack = [songAsset.tracks objectAtIndex:0];
  
  NSDictionary* outputSettingsDict = [[NSDictionary alloc] initWithObjectsAndKeys:
                                      [NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
                                      [NSNumber numberWithInt:1],AVNumberOfChannelsKey,
                                      [NSNumber numberWithInt:8],AVLinearPCMBitDepthKey,
                                      [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,
                                      [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,
                                      [NSNumber numberWithBool:NO],AVLinearPCMIsNonInterleaved,
                                      nil];
  </code></pre>
  
  <p>So how an earth do I get an AVAsset to just work with a filePath URL? </p>
  
  <p>Remember I am trying to get it to view a recorded audio file saved by the app, <strong>NOT</strong> a locally imported audio file which a developer can add into the Xcode project.</p>
  
  <p>I have been stuck on this for days now, if you can help me, that would be much appreciated, thanks.</p>
  
  <p>Thanks for your time, Dan.</p>