Edit

Share via


NSObject.ConformsToProtocol(IntPtr) Method

Definition

Invoked to determine if this object implements the specified protocol.

[Foundation.Export("conformsToProtocol:")]
[Foundation.Preserve]
public virtual bool ConformsToProtocol (IntPtr protocol);
abstract member ConformsToProtocol : nativeint -> bool
override this.ConformsToProtocol : nativeint -> bool

Parameters

protocol
IntPtr

nativeint

Pointer to a protocol.

Returns

Must return true if the class implements the protocol.

Implements

Attributes

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.

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 AdoptsAttribute and let the runtime do this for you, like this:

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

For a complete sample of the AdoptsAttribute see the SimpleTextInput sample

Applies to