| title | iOS Runtime Types |
|---|
NativeScript provides the interop module for working with native C types, pointers, pointer arithmetic and memory.
The Pointer type allows you to represent a void*.
To create a new pointer with the given offset, use the constructor:
const interop1 = new interop.Pointer(34)const interop2 = interop1.add(4)const interop3 = interop1.subtract(3)pointerInstance.toNumber()Converts the value of a Pointer instance to a number.
interop.adopt(ptr: Pointer): AdoptedPointerMakes the specified pointer adopted.
interop.free(ptr: Pointer): voidReleases the memory of the specified unadopted pointer.
interop.sizeof(type: any): numberReturns the size of the provided type. The type can be: a class constructor (of Objective-C interface), an instance (wrapper of Objective-C interface), struct constructor, struct instance, reference, protocol, function (for c function), fundamental types
interop.alloc(size: number): AdoptedPointerAllocates memory size in bytes.
interop.handleof(instance: any): PointerA JavaScript object can obtain a reference to the underlying native object. The instance can represent a class constructor (for an Objective-C interface), an instance (wrapper of an Objective-C interface), a struct instance, a reference, a protocol, a function (for C functions), or a block.
interop.bufferFromData(data: NSData): ArrayBufferWraps an NSData instance in an ArrayBuffer.
Creates a new reference around a JavaScript value. The native representation of the type will be determined during the first time the Reference is used in an operation involving marshalling.
Creates a reference from the pointer with a given type.
Creates a new reference around a value of a certain type.
Creates a function reference that can be marshalled as a native function pointer. The JavaScript reference must be allocated in memory as long as the native code needs the function.
-
"void": Type<void>
-
bool: Type<boolean>
-
int8: Type<number>
-
uint8: Type<number>
-
int16: Type<number>
-
uint16: Type<number>
-
int32: Type<number>
-
uint32: Type<number>
-
int64: Type<number>
-
uint64: Type<number>
-
float: Type<number>
-
double: Type<number>
-
UTF8CString: Type<Reference<number>>
-
unichar: Type<string>
-
id: Type<any>
-
protocol: Type<any>
-
"class": Type<any>
-
selector: Type<string>
Create a new instance of the struct.
Create a new instance of the struct and initialize it from the fields of the provided object.
someStructTypeIntastance.equals(left: T, right: T): booleanChecks two structs for equality.