Created
February 11, 2019 01:37
-
-
Save IshanFx/dc7c6d834a11cf45fee8dc1915d5e6eb to your computer and use it in GitHub Desktop.
iostableview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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