Skip to content

Instantly share code, notes, and snippets.

@Bilguun132
Last active February 22, 2019 03:33
Show Gist options
  • Save Bilguun132/a9d5b4d7a3bd5c61a6aee8faf7566d76 to your computer and use it in GitHub Desktop.
Save Bilguun132/a9d5b4d7a3bd5c61a6aee8faf7566d76 to your computer and use it in GitHub Desktop.
TableView-Tutorial-ViewControllerRefacored
import UIKit
class ViewController: UIViewController {
//declare an outlet and connect to the tableview previously created
@IBOutlet weak var usersTableView: UITableView!
private var userManager = UserManager()
//initialize after self is available
private lazy var userDataSourceProvider = UserDataSourceProvider(userManager: userManager)
override func viewDidLoad() {
super.viewDidLoad()
//set the delegate and datasource to self
usersTableView.register(UINib.init(nibName: "UserTableViewCell", bundle: nil), forCellReuseIdentifier: "cell")
usersTableView.delegate = userDataSourceProvider
usersTableView.dataSource = userDataSourceProvider
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment