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?
You are spelling the selector name wrong.
It's @selector(targetMethod:)
, not @selector(targetMethod)
.
The ":" counts; it's part of the method name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With