It’s the C
type of a method implementation pointer, a function pointer to the function
that implements an Objective-C method. It is defined to return id and takes two
hidden arguments, self and _cmd :
typedef id
(*IMP)(id self,SEL _cmd,…);
To access
IMP, the message ‘methodForSelector’ can be used:
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
It’s the C type of a method implementation pointer, a function pointer to the function that implements an Objective-C method. It is defined to return id and takes two hidden arguments, self and _cmd :
typedef id (*IMP)(id self,SEL _cmd,…);
To access IMP, the message ‘methodForSelector’ can be used:
IMP letsDoSomething = [aObject methodForSelector:@selector(doSomething)];
Now, the method addressed by IMP can be called by dereferencing the IMP,
letsDoSomething(aObject, @selector(doSomething));
And hence, these calls are similar,
[aObject doSomething];
[aObject performSelector:@selector(doSomething)];
[aObject performSelector:NSSelectorFromString(@”doSomething”)];