title: How to add list of songs with sections to UITableView using Swift?
body: <p>I'm trying to create a simple music player that lists all the songs on my device in a <code>UITableView</code> split into alphabetic sections (like the <strong>Apple Music Player</strong>).</p>
  
  <p>There are two areas I can't figure out:</p>
  
  <ol>
  <li>Getting the number of songs per section so that I can create the
  correct number of rows in my table for each section</li>
  <li>Accessing the items in each section to populate the section cells</li>
  </ol>
  
  <p>My code is already pretty long so I'll put the pertinent info here:</p>
  
  <p>I get the list of songs like this:</p>
  
  <pre><code>let songsQry:MPMediaQuery = MPMediaQuery.songsQuery()
  </code></pre>
  
  <p>This is where I'm unsure:</p>
  
  <pre><code>func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      //How can I get the number of songs per Section to return??
      // this does not work:
      return songsQry.itemSections![0].count
  }
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell {
      let cell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "cell")
  
  //How do I get the song for the Section and Row??
      cell.textLabel?.text =  ????
      return cell
  }
  </code></pre>