Last active
January 30, 2020 02:53
-
-
Save clc80/a82bf02bc5f97a11c40821c9d894cf85 to your computer and use it in GitHub Desktop.
UINameTableViewController
This file contains 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 | |
var names = ["Harry Potter", "Hermoine Granger", "Ron Weasley", "Albus Dumbledore", "Draco Malfoy"] | |
class NameTableViewController: UITableViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
// MARK: - Table view data source | |
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
// #warning Incomplete implementation, return the number of rows | |
return names.count | |
} | |
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "NameCell", for: indexPath) | |
let name = names[indexPath.row] | |
cell.textLabel?.text = name | |
return cell | |
} | |
// MARK: - Navigation | |
// In a storyboard-based application, you will often want to do a little preparation before navigation | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
// Get the new view controller using segue.destination. | |
// Pass the selected object to the new view controller. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment