Adds a method to a protocol.
SDKs
- iOS 4.3+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Objective-C Runtime
Declaration
Parameters
proto
The protocol you want to add a method to.
name
The name of the method you want to add.
types
A C string representing the signature of the method you want to add.
isRequiredMethod
A Boolean indicating whether the method is a required method of the
proto
protocol. Iftrue
, the method is a required method; iffalse
, the method is an optional method.isInstanceMethod
A Boolean indicating whether the method is an instance method. If
true
, the method is an instance method; iffalse
, the method is a class method.
Discussion
To add a method to a protocol using this function, the protocol must be under construction. That is, you must add any methods to proto
before you register it with the Objective-C runtime (via the objc
function).