Created
February 5, 2023 21:25
-
-
Save foxicode/8eedf6088454a5c2298f3ef9107cb4b3 to your computer and use it in GitHub Desktop.
Contacts adapter
This file contains hidden or 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 ContactsAdapter: NSObject, UITableViewDelegate, UITableViewDataSource { | |
| var contacts = [Contact]() | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| contacts.count | |
| } | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: ContactCell.cellId, for: indexPath) | |
| if let contactCell = cell as? ContactCell { | |
| contactCell.setContact(contacts[indexPath.row]) | |
| } | |
| return cell | |
| } | |
| func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| tableView.deselectRow(at: indexPath, animated: true) | |
| // TODO: Open contact info | |
| } | |
| func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | |
| 156 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment