AdoptsAttribute AdoptsAttribute Class


An attribute used to specify that a class adopts a specific Objective-C protocol.

[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true)]
public sealed class AdoptsAttribute : Attribute
type AdoptsAttribute = class
    inherit Attribute


You can use this attribute to decorate NSObject-derived classes to report back to the Objective-C runtime that the class adopts the specified Objective-C protocol.

Unlike C# interfaces, Objective-C protocols have optional components which means that they are not directly mapped to C# constructs. In both the Xamarin.iOS and Xamarin.Mac Framework bindings protocols are inlined directly into the classes that adopt the protocols which allow developers to invoke any methods adopted by the system classes.

User subclasses use this attribute when they want to explicitly inform the Objective-C runtime that they adopt the protocol. This attribute is looked up by the NSObject.ConformsToProtocol method.


AdoptsAttribute(String) AdoptsAttribute(String)


ProtocolHandle ProtocolHandle

Returns the underlying handle to the Protocol.

ProtocolType ProtocolType

The name of the protocol type adopted.

Applies to