AdoptsAttribute AdoptsAttribute Class

Definition

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
Inheritance
AdoptsAttributeAdoptsAttribute
Attributes

Remarks

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.

Constructors

AdoptsAttribute(String) AdoptsAttribute(String)

Properties

ProtocolHandle ProtocolHandle

Returns the underlying handle to the Protocol.

ProtocolType ProtocolType

The name of the protocol type adopted.

Applies to