Skip to content

Instantly share code, notes, and snippets.

@X901
Created January 17, 2020 11:52
Show Gist options
  • Save X901/4368bca3af1fdcac2b1d20de52a0eec8 to your computer and use it in GitHub Desktop.
Save X901/4368bca3af1fdcac2b1d20de52a0eec8 to your computer and use it in GitHub Desktop.
////
//ViewController.swift
//BetterExperimentTableview
//
//Created by Basel Baragabah on 16/01/2020.
//Copyright © 2020 Basel Baragabah. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var arrayData = [String]()
override func viewDidLoad() {
super.viewDidLoad()
setUpData()
}
func setUpData(){
for n in 0...200 {
arrayData.append("Cell Number: \(n)")
}
}
}
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arrayData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "dataCell", for: indexPath)
cell.textLabel?.text = arrayData[indexPath.row]
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment