Bagikan melalui


ProtocolAttribute Kelas

Definisi

Atribut diterapkan ke antarmuka yang mewakili protokol Objective-C.

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)]
public sealed class ProtocolAttribute : Attribute
type ProtocolAttribute = class
    inherit Attribute
Warisan
ProtocolAttribute
Atribut

Keterangan

Xamarin.iOS akan mengekspor antarmuka apa pun dengan atribut ini sebagai protokol ke Objective-C, dan kelas apa pun yang mengimplementasikan antarmuka ini akan ditandai sebagai menerapkan protokol yang sesuai saat diekspor ke 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 ()
  {
  }
}

Konstruktor

ProtocolAttribute()

Atribut diterapkan ke antarmuka yang mewakili protokol Objective-C.

Properti

FormalSince

Atribut diterapkan ke antarmuka yang mewakili protokol Objective-C.

IsInformal

Apakah protokol Objective-C adalah protokol informal.

Name

Nama protokol.

WrapperType

Jenis jenis terkelola tertentu yang dapat digunakan untuk membungkus instan protokol ini.

Berlaku untuk