Last active
February 22, 2019 03:33
-
-
Save Bilguun132/a9d5b4d7a3bd5c61a6aee8faf7566d76 to your computer and use it in GitHub Desktop.
TableView-Tutorial-ViewControllerRefacored
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 | |
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