I am writing an iOS application and have a child view controller that I am trying to reference. The child view controller is the delegate of the parent.
At the top of the parent view controller, I have: fileprivate var cameraViewController: CameraViewController<AnyObject>?
In viewDidLoad()
, I have
guard let cameraController = childViewControllers.first as? CameraViewController else {
fatalError("Check storyboard for missing CameraViewController")
}
cameraViewController = cameraController
However, I'm getting the error: Ambiguous reference to member 'first(where:)'
Can anyone explain to me why this is happening? I only have one child view controller for the parent.
CameraViewController needs to be the same everywhere. When I instantiated cameraViewController as a CameraViewController, that needed to be reflected in the second part of the code. The second part should look like this:
guard let cameraController = childViewControllers.first as? CameraViewController<AnyObject> else {
fatalError("Check storyboard for missing CameraViewController")
}
cameraViewController = cameraController