Search code examples
swifttableviewtextfieldsections

Section Names In Table Views


How can I take a text of textfield, and make it as name of a section in a tableview? I want to do this in Swift and Xcode 6. Thank you very much.


Solution

  • You can use titleForHeaderInSection.

    func tableView(tableView: UITableView!, titleForHeaderInSection section: Int) -> String!{
            if (section == 0){
                return textfield.text
            }
            if (section == 1){
                return textfield2.text
            }
        }