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.xcframeworkinto the Xcode project and set it to Embed & Sign, or add theiosfolder as a local Swift package and link itsSlabframework. - Import it with
@import Slab;(modules enabled, the default) or#import <Slab/Slab.h>.
Bridging notes
- Handles are
uint8_t *. Free each with its_freefunction; ARC does not manage them. Wrap them in your own classes withdeallocif 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
NSStringfrom the_ptr/_lenpair withinitWithBytes:length:encoding:. Copy before the next call on that object. - Camera frames: lock a 32BGRA
CVPixelBufferand pass its base address, bytes per row, width and height toslab_frame_set_pixelswithSLAB_PIXEL_BGRA8andcopy = 1. - Threads: one operation at a time per session; run sessions on a
background queue.
slab_session_cancelworks from any thread.
Swift apps can use the Swift API instead.