pureobjc

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package pureobjc provides the runtime support layer for purego-based macOS framework bindings. It exposes retain/release/track helpers and string conversion utilities that generated packages import. Zero CGo dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToObjC

func BoolToObjC(b bool) uintptr

BoolToObjC converts a Go bool to the ObjC BOOL representation (1 or 0).

func GoCString

func GoCString(ptr uintptr) string

GoCString builds a Go string from the address of a null-terminated C string. Generated block adapters use it to convert char* block arguments (purego block callbacks cannot take string parameters directly).

func GoString

func GoString(nsstr objc.ID) string

GoString converts an NSString ObjC object to a Go string.

func NSErrorToError

func NSErrorToError(id objc.ID) error

NSErrorToError converts an NSError ObjC object to a Go error. The returned error is *objcerrors.ObjCError; use errors.As to access structured fields such as Domain, Code, and FailureReason.

func NSString

func NSString(s string) objc.ID

NSString converts a Go string to an autoreleased NSString object. The returned ID is autoreleased; retain it if you need it to outlive the current autorelease pool drain.

func Release

func Release(id objc.ID)

Release sends -release to the given ObjC object.

func Retain

func Retain(id objc.ID) objc.ID

Retain sends -retain to the given ObjC object and returns it unchanged.

func Track

func Track[T Object](o T)

Track registers a Go finalizer on o that releases the underlying ObjC object when o is garbage collected. o must be a pointer type.

Types

type AnyObject

type AnyObject = any

AnyObject is the constraint for ObjC generic type parameters (NSArray[T], NSDictionary[K,V], etc). Using any allows both raw objc.ID handles and fully typed wrapper structs as type arguments without unsafe.Pointer fallback.

type Object

type Object interface {
	Ptr() objc.ID
}

Object is the constraint for generated ObjC wrapper pointer types. Every generated struct (e.g. *NSString, *NSArray) satisfies this interface.

Directories

Path Synopsis
Package objcerrors provides ObjCError, a structured Go error that preserves the full diagnostic payload of an Objective-C NSError: domain, code, localized strings, and any chain of underlying errors.
Package objcerrors provides ObjCError, a structured Go error that preserves the full diagnostic payload of an Objective-C NSError: domain, code, localized strings, and any chain of underlying errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL