---
title: "What is IMP in Objective C?"  
description: "What is IMP in Objective C?"  
author: "Tarun Kumar"  
published: 2015-07-18  
updated: 2020-09-19  
canonical: https://www.mindstick.com/interview/2712/what-is-imp-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# What is IMP in Objective C?

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”)];

## Answers

### Answer by Tarun Kumar

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”)];


---

Original Source: https://www.mindstick.com/interview/2712/what-is-imp-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
