Alphabetical sections in table table view in swift
I have a list of names sorted alphabetically, and now I want display these names in a table view. I'm struggling with grouping these names for each letter. My code looks like this: let sections:Array<AnyObject> = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] var usernames = [String]() func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ let cellID = "cell" let cell: UITableViewCell = self.tv.dequeueReusableCellWithIdentifier(cellID) as UITableViewCell cell.textLabel?.text = usernames