[MonoTouch] SIGSEGV while executing native code

Guido Van Hoecke guivho at gmail.com
Fri Oct 7 09:39:38 EDT 2011


On Fri, Oct 7, 2011 at 13:11, steott at gmail.com <steott at gmail.com> wrote:
> Hi Guido, if you just try to remove the using block for the alert?
> I had the same problem and it was solved in this way.
Well, removing the 'using' clause fixed the problem:

button.Clicked += delegate {
    var alert = new UIAlertView {Title = "alert", Message = "message" };
    alert.AddButton("yes");
    alert.AddButton("no");
    alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
        if (e.ButtonIndex == 0) {
            label.Text = "we got a 'yes'";
        }
        else
        {
            label.Text = "too bad...";
        }
    };
    alert.Show();
};

I must confess that I do not really see the difference with the original:

button.Clicked += delegate {
    using (var alert = new UIAlertView {Title = "alert", Message =
"message" }) {
        alert.AddButton("yes");
        alert.AddButton("no");
        alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
            if (e.ButtonIndex == 0) {
                label.Text = "we got a 'yes'";
            } else {
                label.Text = "too bad...";
            }
        };
        alert.Show();
    }
};

Isn't the variable 'alert' a local temporary variable in both cases?

Well, anyway, my problem is fixed.

Thanx for the help,


Guido.


More information about the MonoTouch mailing list