Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSInvalidArgumentException error in button click - xamarin

I have been following the "Hello, iPhone" tutorial available in xamarin website. I have completed all the steps now. Now, I run the application and click on the "Action 1" button I am getting this error

Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[HelloWorld_iPhoneViewController actionButtonClick:]: unrecognized selector sent to instance 0xb3a5a30 enter image description here How can I fix this issue ? I am using the latest versions of MonoDevelop + MonoTouch

static void Main (string[] args)
    {
        // if you want to use a different Application Delegate class from "AppDelegate"
        // you can specify it here.
        UIApplication.Main (args, null, "AppDelegate"); <-- HERE
    }

my code uploaded to here

like image 845
kakopappa Avatar asked Feb 16 '13 18:02

kakopappa


1 Answers

If you look at the connections for the button (in Xcode) you'll see that you've added 2 actions to the button - one called actionButtonClick and one called actnButtonClick.

In the controller, MonoTouch appears to have only added a partial method for the second action which isn't the one that is crashing.

I deleted the action called actionButtonClick (leaving actnButtonClick) and ran your sample which ran fine.

like image 60
Greg Munn Avatar answered Oct 09 '22 22:10

Greg Munn