objc2
objc2 copied to clipboard
Add some examples/documentation for standard use cases (e..g, getting an ObjC struct into rust)
I'm attempting to use objc2
for Apple iOS API interoperability, and I'm really struggling with basic tasks, such as retrieving an Objective-C struct (simd_float4x4, https://developer.apple.com/documentation/arkit/aranchor/2867981-transform?language=objc) from an object into Rust. Naively, I assumed this would work, but it doesn't:
#[repr(C)]
struct SimdFloat4x4 {
columns: [SimdFloat4; 4],
}
#[repr(C)]
struct SimdFloat4 {
x: f32,
y: f32,
z: f32,
w: f32,
}
and then
let face_transform: SimdFloat4x4 = unsafe { msg_send![anchor, transform] };
Could we have some more examples for things like this?