Comment puis-je regrouper les éléments TableView d'un dictionnaire dans swift?

Considérons cet exemple:

import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 
    @IBOutlet weak var tableView: UITableView!

    var names = ["Vegetables": ["Tomato", "Potato", "Lettuce"], "Fruits": ["Apple", "Banana"]]

        func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{

        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier:"test")

    return cell
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
    return ???
    }
    func numberOfSectionsInTableView(tableView: UITableView) -> Int{      
    return names.count
    }

    func sectionIndexTitlesForTableView(tableView: UITableView) -> [AnyObject]!{

    return ???
    }

    func tableView(tableView: UITableView,
        titleForHeaderInSection section: Int) -> String?{        
    return ????
    }
}

supposons que nous avons besoin que les clés (fruits et légumes) du dictionnaire sont le nombre de sections, plus elles seront les titres des sections. Les éléments de clés (par exemple, les pommes et les bananes) seront les lignes de chaque section. Comment puis-je l'appliquer dans mon code? Je sais que ça peut être facile, mais je ne pouvais pas le comprendre moi-même.

source d'informationauteur Rami Ammoun