0

i'm trying to pass data between viewcontrollers with value is slider's value but it's not work. here's my code ViewController1

ViewController2

TungVuDuc
  • 19
  • 1
  • 6

2 Answers2

0

After looking at your screen shot, I would suggest you to assign simpleString value to destination.myString.

erfan
  • 1,862
  • 11
  • 23
Ajay Singh Mehra
  • 1,220
  • 7
  • 18
0

Your code will always fail because you are trying to cast from a Double to a String. Doing this in Swift gives the following message:

Cast from 'Double' to unrelated type 'String' always fails

What you need to do is have the line of code changed from:

 destination.myString = sender as? String

to:

 destination.myString = String(format:"%f", sender)

or

 destination.myString = "\(sender)"
Benjamin Lowry
  • 3,619
  • 1
  • 21
  • 26