Hello Devs!! Hello from NY o/
On this particular case, I'm make some studying about Dependency Injection and I'm just making a couple mockups to improve my lessons.
By the way, I would like understand more deep why the ...{ coder in ... at my closure be represented a casting with my another class as something like this below:
...
...
That's my another class:
Cheers!!!
On this particular case, I'm make some studying about Dependency Injection and I'm just making a couple mockups to improve my lessons.
By the way, I would like understand more deep why the ...{ coder in ... at my closure be represented a casting with my another class as something like this below:
...
Code Block import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.title = "Movie" } @IBAction func inject(_ sender: Any) { let movie = Movie(title: "GoldenEye 007", genre: "Action", poster: imageLiteral(resourceName: "007 Goldeneye")) guard let moviesDetailsVC = self.storyboard?.instantiateViewController(identifier: "ShowMore", creator: { coder in return MoviewsDetailViewController(coder: coder, movie: movie) }) else { fatalError("MoviesViewController has not been implemented") } self.navigationController?.pushViewController(moviesDetailsVC, animated: true) } }
...
That's my another class:
Code Block import UIKit class MoviewsDetailViewController: UIViewController { @IBOutlet weak var posterImageView: UIImageView! var movie: Movie override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.title = movie.title self.posterImageView.image = movie.poster } init?(coder: NSCoder, movie: Movie) { self.movie = movie super.init(coder: coder) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } }
Cheers!!!