I wanted to make a converter, This is how it works: On the initial screen, it asks from which unit you wanna convert, then when the user clicks on the button it sends the title of the button as string to the next view controller, then using the if statement and checking the the title string to the all units like inch, meter, yard, etc it identifies from which unit we are converting from, then on 'Editing did change' function in the text field it converts and gives the answer I have a problem when it recognises and sends the button title to the next view, what is happening is it is not carrying out the touch up inside function and directly sending the from string which doesn't carry the button title,
Here is the code
class lengthconversions: UIViewController {
var from = "From"
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "answer" {
if let destinationVC = segue.destinationViewController as? lengthconversionsanswer{
destinationVC.from = from
}
}
}
@IBAction func fromunit(sender: AnyObject) {
let buttonTitle = (sender as? UIButton)?.titleLabel?.text
from = buttonTitle!
print(from)
}}
How can I do that the touch up inside function happens and then the data transfer through the segue.
p.s - The button to which the segue is hooked is the same to which the Touch up inside function is used