This is kind of weird. I created a button programatically, but when i press it, it gives me an InvalidArgumentException with an unrecognized selector sent to instance… Here’s how i create the buton:
[placeButton addTarget:self action:@selector(selectPlace)
forControlEvents:UIControlEventTouchUpInside];
And here’s the IBAction:
-(IBAction)selectPlace:(id)sender
{
NSLog(@"didn't work");
}
Now, if i remove the (id)sender parameter from the method, it works without problems. Is there a special property i have t set up for have the (id)sender as a parameter in the IBAction?
Thanks in advance.
You need to put a colon after the method name in the selector, but only when your selector is specifying a method which receives a parameter. In your instance, a colon is required because the method takes the parameter (id)sender.
If your method didn’t have any parameters, you’d be right on the money with no colon.