Passing Data Through Segue (swift 2)

后端 未结 2 1332
傲寒
傲寒 2021-01-29 12:58

This is a Tip Calculator Project and It must have a settings view where I select the default tip rate. I have some issues with passing data, when I select a default tip percenta

2条回答
  •  遥遥无期
    2021-01-29 13:45

    Replace you DefaultRate IBAction with this:

    @IBAction func changevalue(sender: UISegmentedControl) { 
    
        var tipRate = [5, 10, 15, 20, 25, 30]
        tipRates = Double(tipRate[tipControl.selectedSegmentIndex])   
        delegate?.tipPercentageChanged(tipRates!) print("(tipRates)")
        NSUserDefaults.standardUserDefaults().setDouble(tipRates!, forKey: "DefaultTipRate")
        NSUserDefaults.standardUserDefaults().synchronize() 
    }
    

    And set the event as "Value Changed" as shown in the image below

提交回复
热议问题