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
class ViewController: UIViewController { | |
@IBOutlet weak var emptyView: UIView! | |
@IBOutlet weak var tableView: UITableView! | |
@IBOutlet weak var indicatorView: UIActivityIndicatorView! | |
fileprivate let presenter = HousePresenter(dataService: HouseDataService()) | |
fileprivate var houses = [GOTHouse]() | |
override func viewDidLoad() { |
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
protocol HouseViewProtocol: NSObjectProtocol { | |
func showHUD() | |
func hideHUD() | |
func setHouses(_ houses: [GOTHouse]) | |
func setEmptyHouses() | |
} | |
class HousePresenter { | |
fileprivate let dataService: HouseDataService | |
weak fileprivate var houseView: HouseViewProtocol? |
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
class HouseDataService { | |
func getHouses(_ callBack: @escaping ([GOTHouse]) -> Void) { | |
let houses = [GOTHouse(name: "House Targaryen", motto: "Fire And Blood", sigil: "Dragon"), | |
GOTHouse(name: "House Stark", motto: "Winter Is Coming", sigil: "Wolve"), | |
GOTHouse(name: "House Lannister", motto: "Hear Me Roar", sigil: "Lion") | |
] | |
//use delay to simulate network request | |
let delayTime = DispatchTime.now() + .seconds(3) | |
DispatchQueue.main.asyncAfter(deadline: delayTime) { | |
callBack(houses) |
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
struct GOTHouse { | |
let name: String | |
let motto: String | |
let sigil: String | |
} |