How can I pass data between from tableView
to another tableView
? As this example.
Asked
Active
Viewed 663 times
-2

vikingosegundo
- 52,040
- 14
- 137
- 178

J.Arji
- 631
- 6
- 18
-
We need more information. What have you tried? When do you need to pass information? How do you push from one ViewController to another? – Alex Popov Jan 07 '16 at 23:10
-
I passed when I touch cell to the next tableview which is the table has different cells an The number of cells is not fixed. -How do you push from one ViewController to another?it does not important to me – J.Arji Jan 07 '16 at 23:23
-
that is passig data through view controllers – vikingosegundo Jan 07 '16 at 23:23
1 Answers
1
You need to use prepareForSegue and over there you will have the opportunity to pass data to your destination view controller.
Basically you need to set a segue identifier at the connection you made for the second view controller at the storyboard and then you will override (at the first view controller) the method prepareForSegue.
This method will be called automatically by the framework when ever the user will tap the relevant button/cell.
This method initiate your second view controller before the user will see the actual second view controller. You will then have the opportunity to pass/set what ever data you want from the first to the second view controller.
// This will get called before the destination view controller appears
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) {
{
if (segue.identifier == "IdentifierNameYouSet") {
// Get destination view
if let destinationVc = segue.destinationViewController as? YourTableViewControllerName{
// Pass the information to your destination view
destinationVc.propertyArray = yourOriginateVcArray
}
}
}

OhadM
- 4,687
- 1
- 47
- 57
-
-
tank you :) . one question i can't use my data that is save in my swift file for tableView \why ? – J.Arji Jan 08 '16 at 12:56
-