Foundation.NSObject.ConformsToProtocol Method
Invoked to determine if this object implements the specified protocol.

Syntax

[Foundation.Export("conformsToProtocol:")]
[Foundation.Preserve]
public virtual bool ConformsToProtocol (IntPtr protocol)

Parameters

protocol
Pointer to a protocol.

Returns

Must return true if the class implements the protocol.

Remarks

You can override this method if you need your class to respond to Objective-C's query to the object as to whether it implements the specified protocol.

You can compare the IntPtr value with the result of creating an AdoptsAttribute with the specified protocol and fetching its ProtocolHandle.

c# Example

static AdoptsAttribute myProtocol = new AdoptsAttribute ("MyProtocol");
public override ConformsToProtocol (IntPtr protocol)
{
	if (protocol == myProtocol.ProtocolHandle)
		return true;
	return false;
}

Although typically you would merely decorare your class with the ObjCRuntime.AdoptsAttribute and let the runtime do this for you, like this:

c# Example

[Adopts ("UITextInput")]
[Register ("MyCoreView")]
public class EditableCoreTextView : UIView {
	[Export ("inputDelegate")]
	public UITextInputDelegate InputDelegate {...}
}

For a complete sample of the AdoptsAttribute see the SimpleTextInput sample

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0