导航到 swift 中的 popViewController 时无法将委托值添加到 JSON 参数

Unable to add delegate values to JSON parameters while navigating to popViewController in swift

我有两个 Viewcontroller,分别称为 SearchVC 和 filterVC,我有一个 JSON API...这里如果参数为零,那么我需要显示总响应..就像我这样我能做到..

如果我使用 popviewcontroller 委托获取从 filterVC 到 SearchVC 的参数值,那么我需要在参数中显示该值..这是我无法做到的

我在这里创建并添加了值以在 filterVC 中委托:

 struct DataEnteredModelSave {
  var categooryName: String
  var location: String
  var budgetType: String

 }

protocol DataEnteredDelegate: class {
func userDidEnterInformation(info: DataEnteredModelSave)
}
class FilterVC: UIViewController {

weak var delegate: DataEnteredDelegate? = nil

@IBAction func applyBtn(_ sender: Any) {
    if searchServcTf.text != nil{
        let enteredData = DataEnteredModelSave(categooryName: searchServcTf.text ?? "", location: "", budgetType: "")
        delegate?.userDidEnterInformation(info: enteredData)
    }
    else if locationTf.text != nil{
        let enteredData = DataEnteredModelSave(categooryName: "", location: locationTf.text ?? "", budgetType: "")
        delegate?.userDidEnterInformation(info: enteredData)
    }
    else if searchServcTf.text != nil && locationTf.text != nil{
        let enteredData = DataEnteredModelSave(categooryName: searchServcTf.text ?? "", location: locationTf.text ?? "", budgetType: "")
        delegate?.userDidEnterInformation(info: enteredData)
    }
    else{
        let enteredData = DataEnteredModelSave(categooryName: "", location: locationTf.text ?? "", budgetType: "")
        delegate?.userDidEnterInformation(info: enteredData)
    }
    self.navigationController?.popViewController(animated: true)
}

在 SearchVC 中,我将委托值添加到如下参数: 这里 postServiceCalll 在我从 FilterVc 执行 popViewcontroller 时不调用

 class SearchVC: UIViewController, DataEnteredDelegate {

var serviceNmae: String? = ""
var location: String? = ""
var budgetType: String? = ""

@IBAction func filterBtn(_ sender: Any) {
    let vc = Helper.getVcObject(vcName: .SearchFilterVC, StoryBoardName: .Main) as! SearchFilterVC
    vc.delegate = self
    self.checkAndPushPop(vc, navigationController: self.navigationController)
}

func userDidEnterInformation(info: DataEnteredModelSave) {
    print("filter viewcontroller data \(info)")
    self.serviceNmae = info.categooryName
    self.location = info.location
    self.budgetType = info.budgetType
}
func postServiceCalll(){
    
          
    print("serviceName \(serviceNmae) and budgetType \(budgetType)")
    
    let param = ["location" : location, "lat": "", "lng" : "", "nearby": "", "gender": "", "budget": budgetType, "from_date": "", "to_date": "", "min_rate": "", "max_rate": "", "category_select": serviceNmae]

            
    APIReqeustManager.sharedInstance.serviceCall(param: param, method: .post, loaderNeed: true, loadingButton: nil, needViewHideShowAfterLoading: nil, vc: self, url: CommonUrl.search_service_request, isTokenNeeded: true, isErrorAlertNeeded: true, isSuccessAlertNeeded: false, actionErrorOrSuccess: nil, fromLoginPageCallBack: nil){ [weak self] (resp) in
    self?.searchServReq = SearchServiceReqBaseModel(dictionary: resp.dict as NSDictionary? ?? NSDictionary())
        DispatchQueue.main.async {
            self?.tableView.reloadData()
        }
       
    }
}
 }

现在我在 filter viewcontroller data DataEnteredModelSave(categooryName: "Adventure", location: "", budgetType: "")

中获得价值

但是在 postServiceCalll 中没有调用并且 print("serviceName \(serviceNmae) and budgetType \(budgetType)") 值没有出现..为什么我哪里错了..请帮忙

调用它

func userDidEnterInformation(info: DataEnteredModelSave) {
   print("filter viewcontroller data \(info)")
   self.serviceNmae = info.categooryName
   self.location = info.location
   self.budgetType = info.budgetType
   postServiceCalll() //////    << here 
}