Last active
January 29, 2020 04:38
-
-
Save mimthath4/7d02ebf63284e1723edb77af329b758a to your computer and use it in GitHub Desktop.
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 | |
import MINetworkKit | |
class AlbumsViewController: MITableViewController { | |
override func registerCells() { | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "albumCell") | |
updateAlbums() | |
} | |
} | |
extension AlbumsViewController: MINetworkable { | |
func updateAlbums() { | |
send(TypicodeRequest.getAlbums, returns: [Albums]()) { [weak self] result in | |
guard let strongSelf = self else { return } | |
switch result { | |
case .success(let albums): | |
let section = SectionItem(id: "Album", header: nil, items: albums) | |
strongSelf.sections.append(section) | |
DispatchQueue.main.sync { | |
strongSelf.tableView.reloadData() | |
} | |
case .failure(let error): | |
print(error) | |
} | |
} | |
} | |
} | |
extension Album: RowItem { | |
func getCell(at indexPath: IndexPath, of tableView: UITableView) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "albumCell", for: indexPath) | |
cell.textLabel?.text = self.title | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment