How do i pass the value of the text from the UITextField into another view controller. Currently, when I override the func prepareForSegue()
, it is being called before the user finished editing the textfield, so the value passed is always null.
You have a couple of ways to go about this:
text
value of your TextField
instead of your model, which sounds like it is updated after didFinishEditing
didFinishEditing
you can update it every time the text changes by implementing internal func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool
, and getting the new value with let newString = (textField.text! as NSString).stringByReplacingCharactersInRange(range, withString: string)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.