Created
May 6, 2019 12:50
-
-
Save giln/69a7c36eb320da39d41d227e8165c831 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 | |
open class MovieListFetcherViewController: UIViewController { | |
// MARK: - Variables | |
public var movieStore = MovieStore.shared | |
private let listController = ListViewController() | |
public var endpoint: Endpoint = .nowPlaying { | |
didSet { | |
title = endpoint.description | |
} | |
} | |
// MARK: - Lifecycle | |
open override func viewDidLoad() { | |
super.viewDidLoad() | |
title = endpoint.description | |
add(asChildViewController: listController) | |
} | |
open override func viewWillAppear(_ animated: Bool) { | |
super.viewWillAppear(animated) | |
movieStore.fetchMovies(from: endpoint, params: nil, successHandler: { [weak self] moviesResponse in | |
self?.listController.list = moviesResponse.results | |
}) { error in | |
print(error) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment