Passing datas between screens

In my application I want to share between screens few datas (strings or string arrays). I would to know which is the best approach with iOS. Just in case I have to extend UIviewController object I will be grateful if someone can submit or point me a sample code that cover all the class methods and event override, to build a class where I can pass to the constructor an object representing my datas.
I have searched on forum and google but I have not found any sample can put me in the right way.
Thanks in advance,
Max

Posts

  • adamkempadamkemp USInsider, Developer Group Leader mod

    If you are constructing a view controller in code then it's simple: just write a constructor that takes in whatever arguments you want and then pass those in to the constructor when you need to.

    If that doesn't answer your question then please be more specific. In other words, explain what you're trying to do and why it seems difficult.

  • I already have my viewcontroller in code (not coded but I have created the UI with xib files and xCode). Just like this:
    public partial class VmsListController : UIViewController
    {

            UIBarButtonItem logoutButton;
            LoginController loginController;
    
            public VmsListController () : base("VmsListController", null)
            {
                      .....
                     }
    .......
    }
    

    In this situation I would to understand how can I pass my datas through screens I'm navigating.
    Thanks

  • adamkempadamkemp USInsider, Developer Group Leader mod

    If you are using storyboards then read this: http://docs.xamarin.com/guides/ios/user_interface/introduction_to_storyboards/

    If you are writing the code that calls new VmsListController() then just add an argument to its constructor and instead call new VmsListController(arguments...).

  • In this situation:

    public partial class VmsListController : UIViewController
    {
    
            public VmsListController () : base("VmsListController", null)
            {
    //...
            }
    //...
    }
    

    Where do I can specify this class accepts arguments ? Can you show me a sample ?
    THanks.

  • adamkempadamkemp USInsider, Developer Group Leader mod

    It sounds like you need to learn the basics of C#. You can start here: http://msdn.microsoft.com/en-us/library/ms173115.aspx

  • Thanks you give me the right hint.

Sign In or Register to comment.