Skip to content
imaged

Objective-C setup

Apple platforms through the Slab C interface

Objective-C uses Slab's C interface directly, through the Slab framework in Slab.xcframework (iPhone/iPad, Simulator and Mac, arm64). There is no separate wrapper: every function in the C reference is callable as is.

Example: Classify.m.

Add to an app

  • Drag Slab.xcframework into the Xcode project and set it to Embed & Sign, or add the ios folder as a local Swift package and link its Slab framework.
  • Import it with @import Slab; (modules enabled, the default) or #import <Slab/Slab.h>.

Bridging notes

  • Handles are uint8_t *. Free each with its _free function; ARC does not manage them. Wrap them in your own classes with dealloc if you like.
  • Strings in: pass UTF-8 bytes and their length, e.g. NSData *d = [s dataUsingEncoding:NSUTF8StringEncoding] then (uint8_t *)d.bytes, d.length.
  • Strings out: build an NSString from the _ptr / _len pair with initWithBytes:length:encoding:. Copy before the next call on that object.
  • Camera frames: lock a 32BGRA CVPixelBuffer and pass its base address, bytes per row, width and height to slab_frame_set_pixels with SLAB_PIXEL_BGRA8 and copy = 1.
  • Threads: one operation at a time per session; run sessions on a background queue. slab_session_cancel works from any thread.

Swift apps can use the Swift API instead.