如何使用Swift将存储在标签中的数据从我的接口控制器传递到WatchKit中的另一个接口控制器?我似乎无法在任何地方找到答案,希望有人在这里可以帮助我.我已经包含了我的代码部分,它涉及计算我需要传递的值.我基本上想要显示用户计算的相同值,并在下一个名为ResultsController的接口控制器中详细说明.非常感谢任何帮助:D
class InterfaceController: WKInterfaceController {
var currentValue: String = "0"
func setDisplayValue(value: Double)
{
var percent = value
// check if value is an integer
if value % 1 == 0
{
// our value is an integer
currentValue = "\(Int(value))"// new value %
}
else
{
// our value is a float
currentValue = "\(value)"
}
// Display 2 decimal places in final amount
var round = NSString(format:"%.2f", value)
displayLabel.setText("$\(round)") // Display final value
// This value is what …Run Code Online (Sandbox Code Playgroud)