Reputation: 189
I am creating a tab based application using MonoTouch and has a need to pass the data from one tab to another. For example - my default tab loads a list of articles and I need to have that list passed to another tab if user selects it.
At first I thought that I could populate the list in the first view controller and pass it to AppDelegate from where the second view controller can pick it up but that doesn't seem to work.
What is the best way pass data between tabs in iOS? I am looking for MonoTouch example as I am not much familiar with objective-C syntax.
Upvotes: 1
Views: 460
Reputation: 8840
If you are doing this in code rather than using InterfaceBuilder...
Make your own UITabBarController by inheiriting from it. Add your shared data items to that new class. Inherit from UIViewController to create xyzViewController. Add a contructor to this which passes in and stores a reference to your UITabBarController.
You can now ref the common data using the local UITabBarController reference.
If you are using InterfaceBuilder create all the classes and connect them up using outlets.
Upvotes: 1