Home > DeveloperSection > Interviews > What is IMP in Objective C?

Posted on    July-18-2015 12:16 AM

 iPhone iPhone  Ios  Objective C 
 1 Answer(s)
  436  View(s)
Rate this:

Tarun Kumar

Total Post:107

Posted on    July-18-2015 12:16 AM

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”)];


Don't want to miss updates? Please click the below button!

Follow MindStick