objc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT, BSD-2-Clause Imports: 8 Imported by: 57

Documentation

Overview

Package objc implements access to the Objective-C runtime from Go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterClass

func RegisterClass(class Class)

RegisterClass registers a Class with the Objective-C runtime.

func RegisterSelector

func RegisterSelector(name string) unsafe.Pointer

Types

type Class

type Class interface {
	Object

	// AddMethod registers a Go function to be called whenever
	// an instance of the class receives a message for the given
	// selector.
	//
	// The AddMethod call only works for classes created with
	// objc.NewClass. Method calls will only be received by the
	// Go function if instances of the class are instanciated
	// by calling objc.NewGoInstance.
	AddMethod(selector string, fn interface{})

	// Swizzle swaps the implementation of two methods on a class
	// so that messages sent to selectorA are received by the
	// implementation of selectorB and vice-versa.
	Swizzle(selectorA, selectorB string)
}

A Class represents a special Objective-C class Object.

func Get

func Get(name string) Class

Lookup a Class by name

func GetClass

func GetClass(name string) Class

deprecated

func NewClass

func NewClass(classname string, superclass string) Class

func NewClassFromStruct

func NewClassFromStruct(value interface{}) Class

NewClass returns a new class. The value parameter must point to a value of the struct that is used to represent instances of the class in Go.

type Object

type Object interface {
	// SendMsg sends an arbitrary message to the method on the
	// object that is idenfieid by selectorName.
	Send(selector string, args ...interface{}) Object

	// SendSuperMsg is like SendMsg, but sends to the object's
	// super class instead.
	SendSuper(selector string, args ...interface{}) Object

	// Class returns the the special class object corresponding
	// to this object.
	Class() Class

	// Alloc sends the  "alloc" message to the object.
	Alloc() Object

	// Init sends the "init" message to the object.
	Init() Object

	// Retain sends the "retain" message to the object.
	Retain() Object

	// Release sends the "release" message to the object.
	Release() Object

	// AutoRelease sends the "autorelease" message to the object.
	Autorelease() Object

	// Copy sends the "copy" message to the object.
	Copy() Object

	Equals(o Object) bool

	// String returns a string-representation of the object.
	// This is equivalent to sending the "description"
	// message to the object, except that this method
	// returns a Go string.
	String() string

	// Pointer returns the in-memory address of the object.
	Pointer() uintptr

	// Uint returns the value of the object as an uint64.
	Uint() uint64

	// Int returns the value of the object as an int64.
	Int() int64

	// Float returns the value of the object as a float64.
	Float() float64

	// Bool returns the value of the object as a bool.
	Bool() bool

	Set(setter string, args ...interface{})
	Get(getter string) Object
	GetSt(getter string, ret interface{})
}

An Object represents an Objective-C object, along with some convenience methods only found on NSObjects.

func ObjectPtr

func ObjectPtr(ptr uintptr) Object

type Selector

type Selector interface {
	// Selector returns a string representation of
	// a selector.
	Selector() string

	// String returns the same string as Selector does.
	// It is only implemented to implement the Stringer
	// interface.
	String() string
}

A Selector represents an Objective-C method selector.

func GetSelector

func GetSelector(name string) Selector

deprecated

func Sel

func Sel(name string) Selector

GetSelector looks up a Selector by name.

Jump to

Keyboard shortcuts

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