Akrambek Akrambek - 2 years ago 139
iOS Question

How to pass data from PerformSegue in monotouch

I have table source class and on row click I am calling below function to move to another controller but I want to pass some data.


Does any knows how can I achieve it. I am new in monotouch and ios. I cannot figure out how to achieve this.

Answer Source

PrepareForSegue is the right place to do it. For example, if the controller that creates CustomerViewController is called CustomerListViewController, override in CustomerListViewController that method like the following:

public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
    base.PrepareForSegue (segue, sender);

    // do first a control on the Identifier for your segue
    if (segue.Identifier.Equals("your_identifier")) {

        var viewController = (CustomerViewController)segue.DestinationViewController;
        viewController.MyData = dataToInject;

where CustomerViewController has a public property like the following:

public SomeTypeData MyData { get; set; }

You could see this in action in Xamarin samples.

Hope that helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download