0

I intend to build a rather complicated app and I am wondering how to design it correctly.

I have a rootcontroller that is in charge of dispatching the creation of several Controllers (VC1 to VC5), each of them associated with its own storyboard.

So each of these storyboards are quite complex with several levels of controllers usually driven by a navigationcontroller.

My question is the following : let assume that the user is using the deepest controller in the storyboard of VC1. In this controller there is a button. When the user click it I want VC1 and all the controllers linked to it to close and also to have some data sent to the rootcontroller.

My idea is alse to be able to reuse VC1 to VC5 somewhere else in the app but from a different controller than rootcontroller.

What is the best design to achieve that ? Thks

user3239711
  • 639
  • 1
  • 7
  • 24
  • I think it depends on the design and flow of the app. It feels too general. Maybe you can use a UITabBarController? – DatForis May 18 '17 at 09:13

1 Answers1

1

First off, there is no best design.There might be better design in this world for everything.

Your First Quest:

You can use Tabbar Controller with 5 Tabs. Each tab will have navigation controllers for holding your complex design.

For data passing:

  1. Unwind Segue.
  2. Delegates.
  3. Notifications.

For your quest : user click it I want VC1 and all the controllers linked to it to close and also to have some data sent to the rootController.

There are many tutorials of how to go back to root view controller along with data.One of them is passing-data-between-view-controllers I don't want to elaborate this whole procedure but the theme is.

One of many solutions:

  1. Assign that data to destination VC' variable before moving to that VC .For navigation controller, to move to rootView controller,

    [self.navigationController popToRootViewControllerAnimated:YES];

is used. Hope i've given some light. :)

Community
  • 1
  • 1
elk_cloner
  • 2,049
  • 1
  • 12
  • 13
  • Actually I will manage the different with a menu. So VC1 to VC5 will instanciated from there. My question is more linked to data passing and notification. I think it may be a good idea to notify the rootcontroller that it can close VC1. – user3239711 May 18 '17 at 09:40
  • I have already mentioned data passing and i already prioritized it.However if you find my answer useful than it's my pleasure. :) Good day. – elk_cloner May 18 '17 at 09:55