Question

I'm working on updating (i.e. rewriting) a fairly simple iOS app using storyboards (the previous version was using xib files). This rewrite is partially for my own edification since the original app was written by a friend of mine and I'm finally finding some time to dive into iOS myself.

The app uses a Navigation Controller to cycle between view controllers (make/model/size). Each view controller contains a table view with a list of values (makes/models/sizes).

In the xib version, in each view controller I had a unique init method which would accept the info from the previous view controller (e.g.: model view controller needed to know which make was selected - so it could display the appropriate models; size view controller needed to know which make & model were selected - so it could display the appropriate sizes). Also, in the custom init, I would call initWithNibName.

Now, using storyboards, we don't call initWithNibName anymore and we're supposed to hook into awakeFromNib. This works great for the make view controller since it will always show the same list of makes - as it's the root view controller in the nav controller.

Where I'm stuck is how to continue to use storyboards and awakeFromNib but pass data along the way (i.e.: send selected make to model view controller when row in make view controller's table view is selected).

I hope I'm making sense here.

Thanks in advance.

Was it helpful?

Solution

In case of Storyboards, try

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

method. It can be used to pass any message/data to the destinationViewController.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top