T

NativeObjCBridge

The iOS bridge to the Objective-C runtime, scoped to the plugin's capabilities.

type NativeObjCBridge = { … }

Members

alloc(classOrName: string | NativeHandle): NativeHandle

Allocates an instance and initializes it with init, UIKit classes on the main thread; use create for any other initializer.

Converts an NSArray handle to a JavaScript array.

Runs dependent calls in one main-thread pass; a failed step rejects it without undoing earlier steps.

call(handle: NativeHandle, selector: string, ...args: unknown[]): NativeObjCResult

Sends a selector with its arguments on the current runtime thread.

callSuper(handle: NativeHandle, currentClass: string | NativeHandle, selector: string, ...args: unknown[]): NativeObjCResult

Runs the implementation currentClass's superclass provides, like super in Objective-C.

className(handle: NativeHandle): string | null

Returns the class name of the object a handle refers to, or null.

create(classOrName: string | NativeHandle, initSelector: string, args?: unknown[], options?: NativeCallOptions): NativeHandle

Allocates an uninitialized instance, UIKit classes on the main thread unless options.thread says otherwise, and returns what initSelector initializes; throws when that is nil.

Creates a key for attaching a value to objects with setAssociatedObject.

data(value: ArrayBuffer | Uint8Array<ArrayBufferLike>): NativeHandle

Copies bytes into a new NSData object.

Frees a call plan; using it afterwards throws.

Finds the views of a class under or above a view on the main thread. Needs native.objc.snapshot.

Reads the value attached to an object under a key.

getClass(name: string): NativeHandle | null

Looks up a class by name, or returns null when none is registered.

getIvar(handle: NativeHandle, name: string): NativeObjCResult

Reads an instance variable by name, such as _viewModel.

hook<Receiver extends boolean = true>(className: string, selector: string, handlers: NativeHookHandlers<Receiver>, options?: NativeHookOptions<Receiver>): NativeHookToken

Hooks a method by class and selector; handlers run in registration order, and the scope removes the hook on dispose.

invoke(handle: NativeHandle, selector: string, args: unknown[], options?: NativeCallOptions): NativeObjCResult

Sends a selector on the thread options.thread names; main blocks, main-post queues void methods, so prefer invokeAsync or main-post for UI work. Ownership follows Cocoa naming: an alloc, new, copy, mutableCopy or init result is owned by its handle without an extra reference, and the receiver of an init selector stays valid.

invokeAsync(handle: NativeHandle, selector: string, args: unknown[]): NativeCancelablePromise<NativeObjCResult>

Sends a selector on the main thread and resolves with its result. Needs native.objc.invokeAsync.

Calls a prepared selector on an object, on the thread options.thread names, like invoke.

Calls a prepared selector on the main thread and resolves with its result, like invokeAsync.

invokeSuper(handle: NativeHandle, currentClass: string | NativeHandle, selector: string, args: unknown[], options?: NativeCallOptions): NativeObjCResult

Like callSuper with a thread policy; it cannot cross to the main thread synchronously.

invokeSuperAsync(handle: NativeHandle, currentClass: string | NativeHandle, selector: string, args: unknown[]): NativeCancelablePromise<NativeObjCResult>

Runs the superclass implementation on the main thread and resolves with its result.

prepare(handle: NativeHandle, selector: string): NativeObjCCallPlan

Resolves a selector's method signature on an object once, for repeated calls through invokePrepared.

respondsTo(handle: NativeHandle, selector: string): boolean

Checks whether the object responds to a selector.

setAssociatedObject(handle: NativeHandle, key: NativeHandle, value: NativeObjCResult, policy?: string): void

Attaches a value to an object; null clears it. policy is assign, retain, copy, retainNonatomic or copyNonatomic.

setIvar(handle: NativeHandle, name: string, value: NativeObjCResult): void

Writes an instance variable by name.

Reads a UIView subtree in one main-thread pass, as a point-in-time list. Needs native.objc.snapshot.

struct<T extends NativeStructFields = NativeStructFields>(name: string, fields: T): NativeStruct<T>

Builds a registered struct, such as CGRect or UIEdgeInsets, to pass to native calls.