Last active
February 22, 2019 03:27
-
-
Save Bilguun132/ee25cc6b03eabef4106478e6b7fb2516 to your computer and use it in GitHub Desktop.
TableView-Tutorial-UserDataSourceProvider
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 Foundation | |
import UIKit | |
public class UserDataSourceProvider: NSObject, UITableViewDelegate, UITableViewDataSource { | |
//private var to hold the user manager | |
private let userManager: UserManager | |
//initialize the user manager | |
init(userManager: UserManager) { | |
self.userManager = userManager | |
} | |
//tableview delegates declared here | |
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
return userManager.userCount | |
} | |
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! UserTableViewCell | |
cell.configure(user: userManager.getUser(at: indexPath.row)) | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment