Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
NAUSHAD DARUWALLA
1,587 PointsHow to Pass Data Between View Controllers
Hello all, I am having a problem passing data between view controllers. I am trying to take the text from a textfield in one view and add that to an NSArray in another view. I am passing the data from the textfield to the array via an unwind segue and in the method call, i set an index of the array to the textfield text and then try to reload the table view in the unwind segue method call but it doesn't reload the table view. How do I do this?
5 Answers
RASHU BHATNAGAR
Courses Plus Student 2,669 PointsHi Naushad,
this article might help, I referred to this when i was creating an app and it helped me understand the whole process... So Good Luck....
http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers
NAUSHAD DARUWALLA
1,587 PointsI tried this way of unwinding segues but it didn't work, is there any other way to do it?
RASHU BHATNAGAR
Courses Plus Student 2,669 PointsHi naushad, can you post your code here, so that we all can have a better look and help you out better....
NAUSHAD DARUWALLA
1,587 PointsI found out the problem, it actually wasn't about passing data between view controllers at all, it was really only a problem about displaying the data in the table view. This is the code for the unwind segue method in the UITableViewController, how do I add this data to the table view?
-(IBAction)unwindFromAddClassWithDoneButton:(UIStoryboardSegue *)segue {
addClassViewController* source = segue.sourceViewController;
[self.classHierarchyArray addObject:source.textFieldClass];
[self.tableView reloadData];
}
NAUSHAD DARUWALLA
1,587 PointsAnd I've tried to use the [self.tableView reloadData] method but it won't work