This is probably a basic question though I couldn’t find a clear answer. (I’m new to iOS).
This is a quick scheme of my storyboard:
navigationcontroller -> detailviewcontroller -> tableviewcontroller
My detailviewcontroller has 3 buttons. When clicked, they parse an xml from the server and put the elements in an array (called files). (up till here all works fine). So while the array is created, the detail view segues to the tableviewcontroller.
Now my question: how can I pass the array that was created over that segue so I can use it in the tableviewcontroller class to assign the values to the rows? (I know how to assign them, but I don’t know how to pass the array over the segue)
So let’s say I have this code:
if ([segue.identifier isEqualToString:@"pdfSeg"]) {
NSMutableArray *pdfArray = [[NSMutableArray alloc]initWithArray:xmlParser.files];
UITableViewController *tvc = [segue destinationViewController];}
How do I tell the segue to send the pdfArray over so I can fill the rows with pdf files?
Thanks a lot.
Consider the array as the model for the controller. Pass it as a property. Also, do you really want to pass a mutable array? Are you just passing information, or do you expect the controller to manage changes to the array?
So, you add a property…
From within the DestinationViewController interface, add the property…
Synthesize it in the implementation…
Then, provide the property from within prepareForSeque…