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
IsProtocol
Check whether the class represents a protocol or not.
public bool IsProtocol { get; }
Property Value
Name
Get name of class.
public string Name { get; }
Property Value
SuperClass
Get super class.
public Class? SuperClass { get; }
Property Value
Methods
AddProtocol(Class)
Add a protocol to this class.
public void AddProtocol(Class protocol)
Parameters
protocolClassProtocol.
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
superClassClassSuper class.
namestringName of class.
definingAction<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
Returns
- Class
New defined class.
DefineInstanceVariable(string, Type, int)
Define instance variable.
public Variable DefineInstanceVariable(string name, Type type, int elementCount = 1)
Parameters
namestringName of variable.
typeTypeType of variable.
elementCountintNumber 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
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
DefineMethod(Selector, Delegate)
Define method.
public void DefineMethod(Selector name, Delegate implementation)
Parameters
DefineMethod(string, Action<IntPtr, Selector>)
Define method without argument.
public void DefineMethod(string name, Action<IntPtr, Selector> implementation)
Parameters
DefineMethod<TArg1>(Selector, Action<IntPtr, Selector, TArg1>)
Define method with 1 argument.
public void DefineMethod<TArg1>(Selector name, Action<IntPtr, Selector, TArg1> implementation)
Parameters
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
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
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
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
Type Parameters
TArg1TArg2
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
Type Parameters
TArg1R
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
Type Parameters
TArg1TArg2
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
Type Parameters
TArg1R
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
nameSelectorName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3>Implementation.
Type Parameters
TArg1TArg2TArg3
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
nameSelectorName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, R>Implementation.
Type Parameters
TArg1TArg2R
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
namestringName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3>Implementation.
Type Parameters
TArg1TArg2TArg3
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
Type Parameters
TArg1TArg2R
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
nameSelectorName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4
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
nameSelectorName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, R>Implementation.
Type Parameters
TArg1TArg2TArg3R
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
namestringName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4
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
namestringName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, R>Implementation.
Type Parameters
TArg1TArg2TArg3R
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
nameSelectorName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4TArg5
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
nameSelectorName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4R
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
namestringName of method.
implementationAction<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4TArg5
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
namestringName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, R>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4R
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
nameSelectorName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4TArg5R
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
namestringName of method.
implementationFunc<IntPtr, Selector, TArg1, TArg2, TArg3, TArg4, TArg5, R>Implementation.
Type Parameters
TArg1TArg2TArg3TArg4TArg5R
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
namestringName.
getterFunc<IntPtr, Selector, T>Implementation of getter.
setterAction<IntPtr, Selector, T>Implementation of setter.
Returns
- Property
Descriptor of added property.
Type Parameters
TType 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
clsClass
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
FromHandle(IntPtr)
Wrap native instance as Class.
public static Class FromHandle(IntPtr handle)
Parameters
handlenintHandle of instance.
Returns
GetClass(IntPtr)
Get class of given instance.
public static Class GetClass(IntPtr obj)
Parameters
objnintHandle of instance.
Returns
- Class
Class.
GetClass(string)
Find the class with given name.
public static Class? GetClass(string name)
Parameters
namestringName 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
namestringName.
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
namestringName.
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
selectorSelectorSelector.
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
namestringName.
Returns
- Property
Descriptor of found property.
GetProtocol(string)
Find the protocol with given name.
public static Class? GetProtocol(string name)
Parameters
namestringName 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
nameSelectorName.
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
clsClassGiven 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
objnintHandle of instance.
clrObjTBound 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
Returns
- bool
True if CLR object has been bound successfully.