Dynamically provides an implementation for a given selector for an instance method.
- iOS 2.0+
- macOS 10.5+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Objective-C Runtime
The name of a selector to resolve.
true if the method was found and added to the receiver, otherwise
This method and
resolve 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—
_cmd. Using the
class function, you can add a function to a class as a method. Given the following function:
you can use
resolve to dynamically add it to a class as a method (called
resolve) like this: