IOS 10 : TableView tutorial with Swift 3 – most easy way

import UIKit

class ViewController: UIViewController , UITableViewDelegate , UITableViewDataSource{

var names = ["arif","hasnat","ios","developer"]

@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()

tableView.delegate = self
tableView.dataSource = self

}

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

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = names[indexPath.row]
return cell

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *