Skip to content

Instantly share code, notes, and snippets.

@IshanFx
Created February 11, 2019 01:37
Show Gist options
  • Save IshanFx/dc7c6d834a11cf45fee8dc1915d5e6eb to your computer and use it in GitHub Desktop.
Save IshanFx/dc7c6d834a11cf45fee8dc1915d5e6eb to your computer and use it in GitHub Desktop.
iostableview
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
let fruits = ["mango","orange"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
tableView.delegate = self
tableView.dataSource = self
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let table = tableView.dequeueReusableCell(withIdentifier: "tbcell", for: indexPath)
table.textLabel?.text = fruits[indexPath.row]
return table
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruits.count
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment