NSString.CreateNative Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| CreateNative(String, Int32, Int32, Boolean) |
Creates an Objective-C NSString from the C# string and returns a pointer to it. |
| CreateNative(String, Int32, Int32) |
Creates an Objective-C NSString from the C# string and returns a pointer to it. |
| CreateNative(String, Boolean) |
Creates an Objective-C NSString from the C# string and returns a pointer to it. |
| CreateNative(String) |
Creates an Objective-C NSString from the C# string and returns a pointer to it. |
CreateNative(String, Int32, Int32, Boolean)
Creates an Objective-C NSString from the C# string and returns a pointer to it.
public static ObjCRuntime.NativeHandle CreateNative(string? value, int start, int length, bool autorelease);
static member CreateNative : string * int * int * bool -> ObjCRuntime.NativeHandle
Parameters
- value
- String
C# String to wrap
- start
- Int32
The offset of the managed string to create the native string from.
- length
- Int32
The length of the managed string to create the native string from.
- autorelease
- Boolean
Whether the return value is autoreleased (in which case ReleaseNative(NativeHandle) must not be called on the return value).
Returns
Pointer to the NSString object, must be released with ReleaseNative(NativeHandle).
Applies to
CreateNative(String, Int32, Int32)
Creates an Objective-C NSString from the C# string and returns a pointer to it.
public static ObjCRuntime.NativeHandle CreateNative(string? value, int start, int length);
static member CreateNative : string * int * int -> ObjCRuntime.NativeHandle
Parameters
- value
- String
C# String to wrap
- start
- Int32
The offset of the managed string to create the native string from.
- length
- Int32
The length of the managed string to create the native string from.
Returns
Pointer to the NSString object, must be released with ReleaseNative(NativeHandle).
Applies to
CreateNative(String, Boolean)
Creates an Objective-C NSString from the C# string and returns a pointer to it.
public static ObjCRuntime.NativeHandle CreateNative(string? str, bool autorelease);
static member CreateNative : string * bool -> ObjCRuntime.NativeHandle
Parameters
- str
- String
C# String to wrap
- autorelease
- Boolean
Whether the return value is autoreleased (in which case ReleaseNative(NativeHandle) must not be called on the return value).
Returns
Pointer to the NSString object, must be released with ReleaseNative(NativeHandle).
Applies to
CreateNative(String)
Creates an Objective-C NSString from the C# string and returns a pointer to it.
public static ObjCRuntime.NativeHandle CreateNative(string? str);
static member CreateNative : string -> ObjCRuntime.NativeHandle
Parameters
- str
- String
C# String to wrap
Returns
Pointer to the NSString object, must be released with ReleaseNative(NativeHandle).
Remarks
This method creates an Objective-C NSString and returns an NativeHandle 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 Objective-C as it is not necessary for the garbage collector to track this object.
The memory associated with this object should be released by calling the ReleaseNative(NativeHandle) method.
IntPtr objcString = NSString.CreateNative ("Hello");
// You can pass objcString to any methods that expect an Objective-C NSString pointer
NSString.ReleaseNative (objcString);