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,897
  • 13
  • 23
Ajay Singh Mehra
  • 1,313
  • 9
  • 19
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,730
  • 1
  • 23
  • 27