fatal error: Index out of range
<p>I want to show 25 of the songs I have in my library. This is my code:</p>

<pre><code>var allSongsArray: [MPMediaItem] = []
let songsQuery = MPMediaQuery.songsQuery()

func numberOfSectionsInTableView(tableView: UITableView) -&gt; Int {
    return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
    return 25 //allSongsArray.count
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("cell")
    let items = allSongsArray[indexPath.row]
    cell?.textLabel?.text = items.title
    cell?.detailTextLabel?.text = items.artist
    cell?.imageView?.image = items.artwork?.imageWithSize(imageSize)

    return cell!
}
</code></pre>

<p>When I run this, it crashes, because:</p>

<blockquote>
  <p>fatal error: Index out of range</p>
</blockquote>

<p>I tried to change the <code>numberOfRowsInSection</code> to <code>allSongsArray.count</code>, but it ends up with the same error. </p>