Veronica G Veronica G - 1 year ago 91
Swift Question

Segue texfields to a string array

I'm doing an app using swift that takes the entries in 6 text fields and passes them through a segue into an empty string array on a second view controller. How do I do that?

This is my code, is the basics, but I'm not sure how I can send the information through.

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

let destination = segue.destinationViewController as! secondView

if segue.identifier == segueID {

destination.stringArray = ?



The array on my second view controller is this:

var stringArray = [String]()

Answer Source

The shortest way:

destination.stringArray = view.subviews.flatMap { ($0 as? UITextField)?.text }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download