How to send data through segue (swift)
Why Stack Overflow recommends it
Stack Overflow users link it when beginners need a visual walkthrough of passing data between view controllers with prepareForSegue in Swift.
Recommended by 2 people across 2 different months, 2015 to 2016.
What it is
A short 2014 screencast by Matt's Techish Channel showing how to pass data from one view controller to another through a segue in Swift for iOS 8 in Xcode. It walks through a simple text field to label example, with downloadable project files.
What people said
Recommends sahandnayebaziz · 2015-02 · Stack Overflow · on “How to call method from ViewController in GameScene”
I don't have enough rep to reply to your last comment, but if you're still getting that error, that's because you haven't given that segue a name (or identifier) yet in Interface Builder! When you click and drag to draw segues between view controllers in Interface Builder, you can select each transition by the circle icon that appears in the center of the segue lines and give it an 'identifier'. Then, when you call performSegueWithIdentifier , it should work! This is what the circular icon might look like, depending on the type of segue: If you're a little unsure of segues, check out this tutorial [this video] or this one [LINK] !
Recommends Suragch · 2015-08 · Stack Overflow · on “Passing data between view controllers”
Swift There are tons and tons of explanations here and around Stack Overflow, but if you are a beginner just trying to get something basic to work, try watching this YouTube tutorial (It's what helped me to finally understand how to do it). YouTube tutorial: How to send data through segue (Swift) [this video] Passing data forward to the next View Controller The following is an example based on the video. The idea is to pass a string from the text field in the First View Controller to the label in the Second View Controller. [LINK] Create the storyboard layout in the Interface Builder. To make the segue, you just Control click on the button and drag over to the Second View Controller. First View C
Recommends Suragch · 2015-08 · Stack Overflow · on “Passing data between View Controllers using Segue”
This Swift project [this video] on YouTube helped me to finally understand how to do this. I set up a simple example along similar lines. Write some text in a text field, press the button, and it puts the text in a Label in the next View Controller. Setup the storyboard [LINK] It's not very difficult. Create the storyboard layout in the Interface Builder. To make the segue you just control click on the button and drag over to the Second View Controller. First View Controller The code for the First View Controller is import UIKit class FirstViewController: UIViewController { @IBOutlet weak var textField: UITextField! // This function is called before the segue override func prepareForSegue(segue:
Cites Suragch · 2015-08 · Stack Overflow · on “How to pass prepareForSegue: an object”
I came across this question when I was trying to learn how to pass data from one View Controller to another. I need something visual to help me learn though, so this answer is a supplement to the others already here. It is a little more general than the original question but it can be adapted to work. This basic example works like this: [LINK] The idea is to pass a string from the text field in the First View Controller to the label in the Second View Controller. First View Controller import UIKit class FirstViewController: UIViewController { @IBOutlet weak var textField: UITextField! // This function is called before the segue override func prepareForSegue(segue: UIStoryboardSegue, sender:
Cites Joe · 2016-09 · Stack Overflow · on “Prepareforsegue data passing with multiple tableviewControllers in-between?”
Okay so I found some code from a YouTube video where data is passed from one viewController to another and it works fine but, I need it to pass across multiple view controllers and not just one to the other. YouTube Video along with project in desc: [this video] Here is the Code: class ViewController: UIViewController { @IBOutlet weak var textField: UITextField! override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { let nextVC: secondViewController = segue.destinationViewController as! secondViewController nextVC.recevedText = textField.text! } Then the secondViewController code: class secondViewController: UIViewController { var recevedText: String = "" @IBOutlet weak var