代码之家  ›  专栏  ›  技术社区  ›  MinnuKaAnae

从ViewController向ConrainerView传递数据始终为零

  •  0
  • MinnuKaAnae  · 技术社区  · 8 年前

    nil

    CurrentYearView控制器

    //calling this function after getting response, not presenting because it is called from Segmented Control 
    
    func refreshCurrentYearListView(dict: NSDictionary) {
        let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let containerViewController = mainStoryboard.instantiateViewController(withIdentifier: "containerView") as!
        ContainerViewController
        containerViewController.dataDictionary = dict
    }
    

    ContainerViewController

    class ContainerViewController: UIViewController {
    
      @IBOutlet weak var billedValueLbl: UILabel!
      var dataDictionary: NSDictionary!
    
        override func viewDidLoad() {
        super.viewDidLoad()
    
        // Do any additional setup after loading the view.
    
    
      }
    
      override func viewWillAppear(_ animated: Bool) {
    
        if let data = dataDictionary {
            populateJSON(dict: data)
        }
      }
    
      func populateJSON(dict: NSDictionary) {
    
        let N_A: String = "N/A"
        let parser = CommonParser()
    
        let currentYearSalesSummaryDict: NSDictionary = parser.parse(dictionary: dict, key: "currentYearInvoiceSummary")
        if currentYearSalesSummaryDict.count > 0 {
            billedValueLbl.text = parser.parse(dictionary: currentYearSalesSummaryDict, key: "totalInvoiceAmount", exceptionString: N_A)
        }
    }
    
    0 回复  |  直到 8 年前