<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/resolveInstanceMethod(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Objective-C Runtime"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(cm)resolveInstanceMethod:"
  },
  "title" : "resolveInstanceMethod(_:)"
}
-->

# resolveInstanceMethod(_:)

Dynamically provides an implementation for a given selector for an instance method.

```
class func resolveInstanceMethod(_ sel: Selector!) -> Bool
```

## Parameters

`sel`

The name of a selector to resolve.

## Return Value

[`YES`](/documentation/ObjectiveC/YES) if the method was found and added to the receiver, otherwise [`NO`](/documentation/ObjectiveC/NO).

## Discussion

This method and [`resolveClassMethod(_:)`](/documentation/ObjectiveC/NSObject-swift.class/resolveClassMethod(_:)) allow you to dynamically provide an implementation for a given selector.

An Objective-C method is simply a C function that take at least two arguments—`self` and `_cmd`. Using the [`class_addMethod(_:_:_:_:)`](/documentation/ObjectiveC/class_addMethod(_:_:_:_:)) function, you can add a function to a class as a method. Given the following function:

```objc
void dynamicMethodIMP(id self, SEL _cmd)
{
    // implementation ....
}
```

you can use `resolveInstanceMethod:` to dynamically add it to a class as a method (called `resolveThisMethodDynamically`) like this:

```objc
+ (BOOL) resolveInstanceMethod:(SEL)aSEL
{
    if (aSEL == @selector(resolveThisMethodDynamically))
    {
          class_addMethod([self class], aSEL, (IMP) dynamicMethodIMP, "v@:");
          return YES;
    }
    return [super resolveInstanceMethod:aSel];
}
```

### Special Considerations

This method is called before the Objective-C forwarding mechanism is invoked. If [`responds(to:)`](/documentation/ObjectiveC/NSObjectProtocol/responds(to:)) or [`instancesRespond(to:)`](/documentation/ObjectiveC/NSObject-swift.class/instancesRespond(to:)) is invoked, the dynamic method resolver is given the opportunity to provide an `IMP` for the given selector first.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)