Skip to main content
API Reference SwiftyNsdk

NsdkBuffer

A buffer containing binary data for NSDK operations....

Declaration

struct NsdkBuffer

Summary

A buffer containing binary data for NSDK operations. NsdkBuffer provides a safe wrapper around binary data buffers used by various NSDK features. It handles memory management and provides convenient access to buffer data.

Overview

NSDK buffers are used for:

  • Image data transfer
  • Mesh data storage
  • Configuration data
  • Any binary data that needs to be passed between Swift and the native NSDK layer

Example Usage

// Create buffer from Swift Data
let imageData = UIImage(named: "texture")?.pngData()
let buffer = NsdkBuffer(data: imageData!)
// Access buffer data
print("Buffer size: \(buffer.dataSize) bytes")
// Use buffer with NSDK APIs
let status = someArdkFunction(buffer: buffer)

Memory Management

NsdkBuffer automatically manages memory allocation and deallocation. When created from Swift Data, it maintains a reference to prevent premature deallocation.


Constructors

Constructor

init(data: Data)

Overload

init(data: UnsafePointer<UInt8>, dataSize: UInt32)

Properties

NameTypeSummary
let dataUnsafePointer<UInt8>
Pointer to the buffer's binary data.
This provides direct access to the buffer's contents. The data remains
valid as long as the NsdkBuffer instance exists.
let dataSizeUInt32
Size of the buffer data in bytes.
This indicates the total number of bytes available in the buffer.
let ownerResourceOwner?
Resource owner for memory management.
This ensures the buffer's memory is properly managed and deallocated
when the buffer is no longer needed.