passing data back using coordinator pattern?

521 views Asked by At

How to pass data from VC-B to VC-A using coordinator pattern... Im getting error delegate = nil

In MainCoordinator:

func filterView() { 
let filterVC = FilterViewController.instantiate()
filterVC.delegate = self //error : cannot assign value of Type MainCoordinator to type FilterDelegate?
filterVC.coordinator = self
self.navigationController.present(filterVC)
}

In FilterViewController:

protocol FilterDelegate: class {
func data()}
class FilterViewController: UIViewController,StoryBoarded {
var coordinator: MainCoordinator?
weak var delegate: FilterDelegate?

@IBButton func onClick() {
self.delegate.data()
dismiss()
}

In MainViewController:

class MainViewController: UIViewController,FilterDelegate {
var coordinator = MainCoordinator?
func data() {
Print("Data")
}

Tell me any other way to pass data back with coordinator?

0

There are 0 answers