Passing Data Through Segue (swift 2)

我的梦境 提交于 2019-12-02 14:23:01

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

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!