i'm trying to pass data between viewcontrollers with value is slider's value but it's not work. here's my code ViewController1
Asked
Active
Viewed 121 times
0
-
4You need to add code instead of adding image of code, – Nirav D Sep 24 '16 at 09:32
-
Also you need to pass String instead of slider value `performSegue(withIdentifier: "dataPass2", sender: simpleString)`. – Nirav D Sep 24 '16 at 09:35
-
Try this `destination.myString = "\(sliderView.value)"` – Dharmesh Kheni Sep 24 '16 at 09:35
-
Thanks. It's work now ! – TungVuDuc Sep 24 '16 at 09:47
2 Answers
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