ProtocolAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Attribute applied to interfaces that represent Objective-C protocols.
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)]
public sealed class ProtocolAttribute : Attribute
type ProtocolAttribute = class
inherit Attribute
- Inheritance
-
ProtocolAttribute
- Attributes
Remarks
Xamarin.iOS will export any interfaces with this attribute as a protocol to Objective-C, and any classes that implement these interfaces will be marked as implementing the corresponding protocol when exported to Objective-C.
// This will create an Objective-C protocol called 'IMyProtocol', with one required member ('requiredMethod')
[Protocol ("IMyProtocol")]
interface IMyProtocol
{
[Export ("requiredMethod")]
void RequiredMethod ();
}
// This will export the equivalent of "@interface MyClass : NSObject <IMyProtocol>" to Objective-C.
class MyClass : NSObject, IMyProtocol
{
void RequiredMethod ()
{
}
}
Constructors
ProtocolAttribute() |
Properties
FormalSince | |
IsInformal |
Whether the Objective-C protocol is an informal protocol. |
Name |
The name of the protocol. |
WrapperType |
The type of a specific managed type that can be used to wrap an instane of this protocol. |