Share via


Runtime.GetNSObjectChecked<T>(IntPtr) Method

Definition

Wraps an unmanaged IntPtr into a fully typed NSObject, or returns an existing wrapper object if one already exists.

public static T? GetNSObjectChecked<T>(IntPtr ptr) where T : Foundation.NSObject;
static member GetNSObjectChecked : nativeint -> 'T (requires 'T :> Foundation.NSObject)

Type Parameters

T

Type to wrap the native object as.

Parameters

ptr
IntPtr

nativeint

A pointer to an unmanaged NSObject or any class that derives from the Objective-C NSObject class.

Returns

T

An instance of the class T.

Remarks

Contrary to GetNSObject<T>(IntPtr), this method will throw an exception if the native object's type is not compatible with T.

This method will fail if there already is a managed wrapper of a different and incompatible type for the native object.

Applies to