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 MyProtocol { | |
| var sharedInstance: Any? { get set } | |
| } |
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
| final class DefaultMyProtocol: MyProtocol { | |
| var sharedInstance: Any? = nil | |
| } |
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
| final class MyProtocolSharedInstanceSetter { | |
| private let myProtocol: MyProtocol | |
| init(myProtocol: MyProtocol, myApi: MyApi) { | |
| self.myProtocol = myProtocol | |
| myApi.getRequest(onCompletion: { [weak self] in myProtocol.sharedInstance = $0 } | |
| } | |
| } |
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 MyProtocol: class { | |
| var sharedInstance: Any? { get set } | |
| } |
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
| #!/bin/bash | |
| realpath() { | |
| [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | |
| } | |
| FILE_PATH=$(realpath $0) | |
| # File directory path | |
| DIR_NAME=$(dirname "${FILE_PATH}") |
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 MoviesViewModel { | |
| let movies: [MovieCellViewModel] | |
| init(movies: [MovieCellViewModel]) { | |
| self.movies = movies | |
| } | |
| } | |
| struct MovieCellViewModel { |
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 Foundation | |
| import UIKit | |
| final class MoviesTableViewDataSource: NSObject, UITableViewDataSource { | |
| var viewModels: [MovieCellViewModel] = [] | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return self.viewModels.count | |
| } |
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
| func set(viewModel: MoviesViewModel) { | |
| self.viewModel = viewModel | |
| if self.isViewLoaded { | |
| self.bind(viewModel: viewModel) | |
| } | |
| } | |
| private func bind(viewModel: MoviesViewModel) { |
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
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "MovieCell") | |
| self.dataSource = MoviesTableViewDataSource() | |
| self.tableView.dataSource = self.dataSource | |
| if let viewModel = self.viewModel { |
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 Foundation | |
| import UIKit | |
| final class MoviesViewCoordinator { | |
| private let navigationController: UINavigationController | |
| init(navigationController: UINavigationController) { | |
| self.navigationController = navigationController | |
| } |
OlderNewer