module UI::ObjC

Overview

Factory methods for creating NativeHandle instances that wrap ObjC objects.

Each factory encodes the correct ReleaseStrategy for the ownership model:

All factories are gated behind flag?(:darwin) to ensure zero ObjC code compiles on non-Apple platforms.

Defined in:

ui/native/objc_handle.cr

Class Method Summary

Class Method Detail

def self.borrowed(ptr : Pointer(Void), label : String | Nil = nil) : NativeHandle #

Wrap a borrowed ObjC pointer that Crystal does NOT own. No release action will be taken.


[View source]
def self.class_ref(ptr : Pointer(Void), label : String | Nil = nil) : NativeHandle #

Wrap an ObjC class object pointer. Class objects are singletons managed by the ObjC runtime and are never released. Uses Unowned strategy.


[View source]
def self.owned(ptr : Pointer(Void), label : String | Nil = nil) : NativeHandle #

Wrap an ObjC pointer that Crystal already owns (+1 retain count). The handle will call objc_release when released.


[View source]
def self.retain(ptr : Pointer(Void), label : String | Nil = nil) : NativeHandle #

Retain an ObjC pointer (+1) and wrap it as owned. Use when you need to extend the lifetime of an autoreleased object.


[View source]