Table of Contents

Class Class

Namespace
CarinaStudio.MacOS.ObjectiveC
Assembly
CarinaStudio.AppBase.MacOS.dll

Class of Objective-C.

public sealed class Class : IEquatable<Class>
Inheritance
Class
Implements
Inherited Members
Extension Methods

Properties

Handle

Get handle of class.

public IntPtr Handle { get; }

Property Value

nint

IsProtocol

Check whether the class represents a protocol or not.

public bool IsProtocol { get; }

Property Value

bool

Name

Get name of class.

public string Name { get; }

Property Value

string

SuperClass

Get super class.

public Class? SuperClass { get; }

Property Value

Class

Methods

AddProtocol(Class)

Add a protocol to this class.

public void AddProtocol(Class protocol)

Parameters

protocol Class

Protocol.

Allocate()

Allocate memory for new instance with this class.

public IntPtr Allocate()

Returns

nint

Handle of allocated instance.

DefineClass(Class?, string, Action<Class>)

Define a new class.

public static Class DefineClass(Class? superClass, string name, Action<Class> defining)

Parameters

superClass Class

Super class.

name string

Name of class.

defining Action<Class>

Action to define members of class.

Returns

Class

New defined class.

DefineClass(string, Action<Class>)

Define a new class extends from NSObject.

public static Class DefineClass(string name, Action<Class> defining)

Parameters

name string

Name of class.

defining Action<Class>

Action to define members of class.

Returns

Class

New defined class.

DefineInstanceVariable(string, Type, int)

Define instance variable.

public Variable DefineInstanceVariable(string name, Type type, int elementCount = 1)

Parameters

name string

Name of variable.

type Type

Type of variable.

elementCount int

Number of element is value is an array.

Returns

Variable

Descriptor of instance variable.

DefineInstanceVariable<T>(string, int)

Define instance variable.

public Variable DefineInstanceVariable<T>(string name, int elementCount = 1)

Parameters

name string

Name of variable.

elementCount int

Number of element is value is an array.

Returns

Variable

Descriptor of instance variable.

Type Parameters

T

DefineMethod(Selector, Action<IntPtr, Selector>)

Define method without argument.

public void DefineMethod(Selector name, Action<IntPtr, Selector> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector>

Implementation.

DefineMethod(Selector, Delegate)

Define method.

public void DefineMethod(Selector name, Delegate implementation)

Parameters

name Selector

Name of method.

implementation Delegate

Implementation.

DefineMethod(string, Action<IntPtr, Selector>)

Define method without argument.

public void DefineMethod(string name, Action<IntPtr, Selector> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector>

Implementation.

DefineMethod<TArg1>(Selector, Action<IntPtr, Selector, TArg1>)

Define method with 1 argument.

public void DefineMethod<TArg1>(Selector name, Action<IntPtr, Selector, TArg1> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector, TArg1>

Implementation.

Type Parameters

TArg1

DefineMethod<R>(Selector, Func<IntPtr, Selector, R>)

Define method without argument.

public void DefineMethod<R>(Selector name, Func<IntPtr, Selector, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, R>

Implementation.

Type Parameters

R

DefineMethod<TArg1>(string, Action<IntPtr, Selector, TArg1>)

Define method with 1 argument.

public void DefineMethod<TArg1>(string name, Action<IntPtr, Selector, TArg1> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector, TArg1>

Implementation.

Type Parameters

TArg1

DefineMethod<R>(string, Func<IntPtr, Selector, R>)

Define method without argument.

public void DefineMethod<R>(string name, Func<IntPtr, Selector, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, R>

Implementation.

Type Parameters

R

DefineMethod<TArg1, TArg2>(Selector, Action<IntPtr, Selector, TArg1, TArg2>)

Define method with 2 arguments.

public void DefineMethod<TArg1, TArg2>(Selector name, Action<IntPtr, Selector, TArg1, TArg2> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2>

Implementation.

Type Parameters

TArg1
TArg2

DefineMethod<TArg1, R>(Selector, Func<IntPtr, Selector, TArg1, R>)

Define method with 1 argument.

public void DefineMethod<TArg1, R>(Selector name, Func<IntPtr, Selector, TArg1, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, TArg1, R>

Implementation.

Type Parameters

TArg1
R

DefineMethod<TArg1, TArg2>(string, Action<IntPtr, Selector, TArg1, TArg2>)

Define method with 2 arguments.

public void DefineMethod<TArg1, TArg2>(string name, Action<IntPtr, Selector, TArg1, TArg2> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2>

Implementation.

Type Parameters

TArg1
TArg2

DefineMethod<TArg1, R>(string, Func<IntPtr, Selector, TArg1, R>)

Define method with 1 argument.

public void DefineMethod<TArg1, R>(string name, Func<IntPtr, Selector, TArg1, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, TArg1, R>

Implementation.

Type Parameters

TArg1
R

DefineMethod<TArg1, TArg2, TArg3>(Selector, Action<IntPtr, Selector, TArg1, TArg2, TArg3>)

Define method with 3 arguments.

public void DefineMethod<TArg1, TArg2, TArg3>(Selector name, Action<IntPtr, Selector, TArg1, TArg2, TArg3> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3>

Implementation.

Type Parameters

TArg1
TArg2
TArg3

DefineMethod<TArg1, TArg2, R>(Selector, Func<IntPtr, Selector, TArg1, TArg2, R>)

Define method with 2 arguments.

public void DefineMethod<TArg1, TArg2, R>(Selector name, Func<IntPtr, Selector, TArg1, TArg2, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, R>

Implementation.

Type Parameters

TArg1
TArg2
R

DefineMethod<TArg1, TArg2, TArg3>(string, Action<IntPtr, Selector, TArg1, TArg2, TArg3>)

Define method with 3 arguments.

public void DefineMethod<TArg1, TArg2, TArg3>(string name, Action<IntPtr, Selector, TArg1, TArg2, TArg3> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3>

Implementation.

Type Parameters

TArg1
TArg2
TArg3

DefineMethod<TArg1, TArg2, R>(string, Func<IntPtr, Selector, TArg1, TArg2, R>)

Define method with 2 arguments.

public void DefineMethod<TArg1, TArg2, R>(string name, Func<IntPtr, Selector, TArg1, TArg2, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, R>

Implementation.

Type Parameters

TArg1
TArg2
R

DefineMethod<TArg1, TArg2, TArg3, TArg4>(Selector, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>)

Define method with 4 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4>(Selector name, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4

DefineMethod<TArg1, TArg2, TArg3, R>(Selector, Func<IntPtr, Selector, TArg1, TArg2, TArg3, R>)

Define method with 3 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, R>(Selector name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
R

DefineMethod<TArg1, TArg2, TArg3, TArg4>(string, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>)

Define method with 4 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4>(string name, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4

DefineMethod<TArg1, TArg2, TArg3, R>(string, Func<IntPtr, Selector, TArg1, TArg2, TArg3, R>)

Define method with 3 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, R>(string name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
R

DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5>(Selector, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>)

Define method with 5 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5>(Selector name, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5> implementation)

Parameters

name Selector

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
TArg5

DefineMethod<TArg1, TArg2, TArg3, TArg4, R>(Selector, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>)

Define method with 4 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, R>(Selector name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
R

DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5>(string, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>)

Define method with 5 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5>(string name, Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5> implementation)

Parameters

name string

Name of method.

implementation Action<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
TArg5

DefineMethod<TArg1, TArg2, TArg3, TArg4, R>(string, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>)

Define method with 4 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, R>(string name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
R

DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5, R>(Selector, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>)

Define method with 5 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5, R>(Selector name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R> implementation)

Parameters

name Selector

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
TArg5
R

DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5, R>(string, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>)

Define method with 5 arguments.

public void DefineMethod<TArg1, TArg2, TArg3, TArg4, TArg5, R>(string name, Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R> implementation)

Parameters

name string

Name of method.

implementation Func<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>

Implementation.

Type Parameters

TArg1
TArg2
TArg3
TArg4
TArg5
R

DefineProperty<T>(string, Func<IntPtr, Selector, T>, Action<IntPtr, Selector, T>?)

Add new property to this class.

public Property DefineProperty<T>(string name, Func<IntPtr, Selector, T> getter, Action<IntPtr, Selector, T>? setter = null) where T : struct

Parameters

name string

Name.

getter Func<IntPtr, Selector, T>

Implementation of getter.

setter Action<IntPtr, Selector, T>

Implementation of setter.

Returns

Property

Descriptor of added property.

Type Parameters

T

Type of property value.

Equals(Class?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Class? cls)

Parameters

cls Class

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

FromHandle(IntPtr)

Wrap native instance as Class.

public static Class FromHandle(IntPtr handle)

Parameters

handle nint

Handle of instance.

Returns

Class

Class.

GetClass(IntPtr)

Get class of given instance.

public static Class GetClass(IntPtr obj)

Parameters

obj nint

Handle of instance.

Returns

Class

Class.

GetClass(string)

Find the class with given name.

public static Class? GetClass(string name)

Parameters

name string

Name of class.

Returns

Class

Class with given name, or Null if class cannot be found.

GetClassVariable(string)

Get class variable defined by this class.

public Variable? GetClassVariable(string name)

Parameters

name string

Name.

Returns

Variable

Descriptor of class variable.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetInstanceVariable(string)

Get instance variable defined by this class.

public Variable? GetInstanceVariable(string name)

Parameters

name string

Name.

Returns

Variable

Descriptor of instance variable.

GetInstanceVariables()

Get all instance variables of the class. Instance variables defined by super classes are excluded.

public Variable[] GetInstanceVariables()

Returns

Variable[]

Descriptors of instance variables.

GetMethod(Selector)

Get method with specific selector.

public Method? GetMethod(Selector selector)

Parameters

selector Selector

Selector.

Returns

Method

Method with specific selector, or Null if method cannot be found.

GetMethods()

Get all methods of this class.

public Method[] GetMethods()

Returns

Method[]

Descriptors of methods.

GetProperties()

Get all properties of the class. Properties defined by super classes are excluded.

public Property[] GetProperties()

Returns

Property[]

Descriptors of properties.

GetProperty(string)

Get property defined by this class.

public Property? GetProperty(string name)

Parameters

name string

Name.

Returns

Property

Descriptor of found property.

GetProtocol(string)

Find the protocol with given name.

public static Class? GetProtocol(string name)

Parameters

name string

Name of protocol.

Returns

Class

Protocol with given name, or Null if protocol cannot be found.

HasMethod(Selector)

Check whether given method is implemented by this class or not.

public bool HasMethod(Selector name)

Parameters

name Selector

Name.

Returns

bool

True if method is implemented by this class.

IsAssignableFrom(Class)

Check whether instances of given class can be casted to this class or not.

public bool IsAssignableFrom(Class cls)

Parameters

cls Class

Given class.

Returns

bool

True if instances of given class can be casted to this class.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetClrObject<T>(IntPtr, out T?)

Try getting CLR object bound to Object-C object by calling TrySetClrObject(IntPtr, object?).

public bool TryGetClrObject<T>(IntPtr obj, out T? clrObj)

Parameters

obj nint

Handle of instance.

clrObj T

Bound CLR object.

Returns

bool

True if CLR object found.

Type Parameters

T

TrySetClrObject(IntPtr, object?)

Try binding CLR object to given Objective-C object.

public bool TrySetClrObject(IntPtr obj, object? clrObj)

Parameters

obj nint

Handle of instance.

clrObj object

CLR object to bind.

Returns

bool

True if CLR object has been bound successfully.