Share via


Runtime.GetNSObject Method

Definition

Overloads

GetNSObject(IntPtr)

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

GetNSObject(NativeHandle, Boolean)

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

GetNSObject(NativeHandle)
GetNSObject<T>(IntPtr)

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

GetNSObject<T>(IntPtr, Boolean)

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

GetNSObject(IntPtr)

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

public static Foundation.NSObject? GetNSObject(IntPtr ptr);
static member GetNSObject : nativeint -> Foundation.NSObject

Parameters

ptr
IntPtr

nativeint

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

Returns

An instance of a class that derives from Foundation.NSObject.

Remarks

The runtime create an instance of the most derived class.

Applies to

GetNSObject(NativeHandle, Boolean)

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

public static Foundation.NSObject? GetNSObject(ObjCRuntime.NativeHandle ptr, bool owns);
static member GetNSObject : ObjCRuntime.NativeHandle * bool -> Foundation.NSObject

Parameters

ptr
NativeHandle

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

owns
Boolean

Pass true if the caller has a reference to the native object, and wants to give it to the managed wrapper instance. Otherwise pass false (and the native object will be retained if needed).

Returns

An instance of a class that derives NSObject.

Remarks

The runtime create an instance of the most derived managed class.

Applies to

GetNSObject(NativeHandle)

public static Foundation.NSObject? GetNSObject(ObjCRuntime.NativeHandle ptr);
static member GetNSObject : ObjCRuntime.NativeHandle -> Foundation.NSObject

Parameters

Returns

Applies to

GetNSObject<T>(IntPtr)

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

public static T? GetNSObject<T>(IntPtr ptr) where T : Foundation.NSObject;
static member GetNSObject : 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

Returns an instance of the T class even if the native object is not in the class hierarchy of T (no type checks).

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

Applies to

GetNSObject<T>(IntPtr, Boolean)

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

public static T? GetNSObject<T>(IntPtr ptr, bool owns) where T : Foundation.NSObject;
static member GetNSObject : nativeint * bool -> '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.

owns
Boolean

Pass true if the caller has a reference to the native object, and wants to give it to the managed wrapper instance. Otherwise pass false (and the native object will be retained).

Returns

T

An instance of the T class.

Remarks

Returns an instance of the T class even if the native object is not in the class hierarchy of T (no type checks).

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

Applies to