Contents

class_conformsToProtocol(_:_:)

Returns a Boolean value that indicates whether a class conforms to a given protocol.

Declaration

func class_conformsToProtocol(_ cls: AnyClass?, _ protocol: Protocol?) -> Bool

Parameters

  • cls:

    The class you want to inspect.

  • protocol:

    A protocol.

Return Value

YES if cls conforms to protocol, otherwise NO.

Discussion

You should usually use NSObject’s conforms(to:) method instead of this function.

See Also

Working with Classes