Edytuj

Udostępnij za pośrednictwem


NSString.CreateNative Method

Definition

Overloads

CreateNative(String, Int32, Int32, Boolean)
CreateNative(String, Int32, Int32)
CreateNative(String)

Creates an Objective-C NSString from the C# string and returns a pointer to it.

CreateNative(String, Boolean)

CreateNative(String, Int32, Int32, Boolean)

public static IntPtr CreateNative (string value, int start, int length, bool autorelease);
static member CreateNative : string * int * int * bool -> nativeint

Parameters

value
String
start
Int32
length
Int32
autorelease
Boolean

Returns

IntPtr

nativeint

Applies to

CreateNative(String, Int32, Int32)

public static IntPtr CreateNative (string value, int start, int length);
static member CreateNative : string * int * int -> nativeint

Parameters

value
String
start
Int32
length
Int32

Returns

IntPtr

nativeint

Applies to

CreateNative(String)

Creates an Objective-C NSString from the C# string and returns a pointer to it.

public static IntPtr CreateNative (string str);
static member CreateNative : string -> nativeint

Parameters

str
String

C# String to wrap

Returns

IntPtr

nativeint

Pointer to the NSString object, must be released with ReleaseNative.

Remarks

This method creates an Objective-C NSString and returns an IntPtr that points to it. This does not create the managed NSString object that points to it, which is ideal for transient strings that must be passed to Objectiv-C as it is not necessary for Mono's Garbage collector or the MonoTouch/Xamarin.Mac Framework engines to track this object.

The memory associated with this object should be released by calling the ReleaseNative(IntPtr) method.

IntPtr objcString = NSString.CreateNative ("Hello");
// You can pass objcString to any methods that expect an Objective-C NSString pointer
NSString.ReleaseNative (objcString);

Applies to

CreateNative(String, Boolean)

public static IntPtr CreateNative (string str, bool autorelease);
static member CreateNative : string * bool -> nativeint

Parameters

str
String
autorelease
Boolean

Returns

IntPtr

nativeint

Applies to