-
Notifications
You must be signed in to change notification settings - Fork 1
/
ListViewController.swift
38 lines (30 loc) · 1.21 KB
/
ListViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// ListViewController.swift
// SimpleBrowser
//
// Created by Julian Moorhouse on 10/07/2019.
// Copyright © 2019 Mindwarp Consultancy Ltd. All rights reserved.
//
import UIKit
class ListViewController: UITableViewController {
var websites = ["apple.com", "hackingwithswift.com"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return websites.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Website", for: indexPath)
cell.textLabel?.text = websites[indexPath.row]
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let vc = storyboard?.instantiateViewController(withIdentifier: "Detail") as? ViewController {
vc.websites = websites
vc.selectedWebsiteIndex = indexPath.row
navigationController?.pushViewController(vc, animated: true)
}
}
}