import Foundation
import RentalsService
class RentalsViewController: UIViewController {
var rentalService: Rentals
init(rentalService: Rentals) {
self.rentalService = rentalService
super.init(nibName: "RentalsViewController", bundle: NSBundle.mainBundle())
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) // problem here
}
}
I want rentalService variable to be non-optional. i.e. you can't have a rentalsVC without the service. However, I'm forced to declare init(NSCoder) - but I don't have access to a rental service implementation at this point.
Rentals is a protocol, and I'm using dependency injection - so one doesn't create the dependency inside the class.
Anyone got any clever ideas to overcome this? Or what is the preffered pattern / best practice?