objc

package module
v0.0.0-...-7599ab5 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2013 License: BSD-2-Clause Imports: 7 Imported by: 4

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.

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{})
}

A Class represents a special Objective-C class Object.

func GetClass

func GetClass(name string) Class

Lookup a Class by name

func NewClass

func NewClass(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.
	SendMsg(selectorName string, args ...interface{}) Object

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

	// 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

	// 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
}

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

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

GetSelector looks up a Selector by name.

Directories

Path Synopsis
Package appkit implements access to Mac OS X's AppKit.framework
Package appkit implements access to Mac OS X's AppKit.framework
Package foundation implements access to Mac OS X's Foundation.framework
Package foundation implements access to Mac OS X's Foundation.framework

Jump to

Keyboard shortcuts

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