Passing Data Through Segue (swift 2)

后端 未结 2 1333
傲寒
傲寒 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

    0 讨论(0)
  • 2021-01-29 13:53

    I strongly recommend you go through a few introductory iOS & Swift tutorials online. SO is not the place to get beginner level understanding of programming topics. Some recommended tutorials:

    Swift 2 Tutorial

    Apple swift tutorials

    0 讨论(0)
提交回复
热议问题