Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trying to get simplest possible example of performSelector: withObject working

Tags:

objective-c

Here's my method signature for "targetMethod":

-(void)targetMethod: (id)arg;

This works:

[myObject targetMethod:@"called the regular way"];

This doesn't

[myObject performSelector:@selector(targetMethod) withObject:@"called using selector"];

It results in the following error:

-[SelectorTest targetMethod]: unrecognized selector sent to instance 0x4e075d0

What am I doing wrong?

like image 370
morgancodes Avatar asked Nov 12 '10 03:11

morgancodes


1 Answers

You are spelling the selector name wrong.

It's @selector(targetMethod:), not @selector(targetMethod).

The ":" counts; it's part of the method name.

like image 154
David Gelhar Avatar answered Oct 19 '22 23:10

David Gelhar