Table of Contents

Class NSObject

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

Object of Objective-C.

public class NSObject : IDisposable, IEquatable<NSObject>
Inheritance
NSObject
Implements
Derived
Inherited Members
Extension Methods

Constructors

NSObject(Class, IntPtr, bool)

Initialize new NSObject instance.

protected NSObject(Class cls, IntPtr handle, bool ownsInstance)

Parameters

cls Class

Class of instance.

handle nint

Handle of instance.

ownsInstance bool

True to own the instance.

NSObject(IntPtr, bool)

Initialize new NSObject instance.

protected NSObject(IntPtr handle, bool ownsInstance)

Parameters

handle nint

Handle of instance.

ownsInstance bool

True to own the instance.

Properties

Class

Get class of instance.

public Class Class { get; }

Property Value

Class

Handle

Get handle of instance.

public IntPtr Handle { get; }

Property Value

nint

IsDefaultInstance

Check whether the instance is default instance which cannot be disposed.

public bool IsDefaultInstance { get; protected set; }

Property Value

bool

IsReleased

Check whether instance has been released or not.

public bool IsReleased { get; }

Property Value

bool

Methods

Equals(NSObject?)

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

public bool Equals(NSObject? obj)

Parameters

obj NSObject

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.

~NSObject()

Finalizer.

protected ~NSObject()

FromHandle(IntPtr, bool)

Wrap given handle as NSObject.

public static NSObject? FromHandle(IntPtr handle, bool ownsInstance = false)

Parameters

handle nint

Handle of instance.

ownsInstance bool

True to owns instance.

Returns

NSObject

Wrapped instance, or Null if handle is Zero.

FromHandle(Type, IntPtr, bool)

Wrap given handle as given type.

public static NSObject? FromHandle(Type type, IntPtr handle, bool ownsInstance = false)

Parameters

type Type

Type to wrap the instance.

handle nint

Handle of instance.

ownsInstance bool

True to owns instance.

Returns

NSObject

Wrapped instance, or Null if handle is Zero.

FromHandle<T>(IntPtr, bool)

Wrap given handle as given type.

public static T? FromHandle<T>(IntPtr handle, bool ownsInstance = false) where T : NSObject

Parameters

handle nint

Handle of instance.

ownsInstance bool

True to owns instance.

Returns

T

Wrapped instance, or Null if handle is Zero.

Type Parameters

T

Type to wrap the instance.

GetBooleanProperty(Property)

Get value of property as bool.

public bool GetBooleanProperty(Property property)

Parameters

property Property

Property.

Returns

bool

Value.

GetDoubleProperty(Property)

Get value of property as double.

public double GetDoubleProperty(Property property)

Parameters

property Property

Property.

Returns

double

Value.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetInt32Property(Property)

Get value of property as int.

public int GetInt32Property(Property property)

Parameters

property Property

Property.

Returns

int

Value.

GetIntPtrProperty(Property)

Get value of property as nint.

public nint GetIntPtrProperty(Property property)

Parameters

property Property

Property.

Returns

nint

Value.

GetNSObjectProperty<T>(Property)

Get value of property as NSObject.

public T? GetNSObjectProperty<T>(Property property) where T : NSObject

Parameters

property Property

Property.

Returns

T

Value.

Type Parameters

T

GetProperty<T>(Property)

Get value of property as given type.

public T GetProperty<T>(Property property)

Parameters

property Property

Property.

Returns

T

Value.

Type Parameters

T

GetSingleProperty(Property)

Get value of property as float.

public float GetSingleProperty(Property property)

Parameters

property Property

Property.

Returns

float

Value.

GetUInt32Property(Property)

Get value of property as uint.

public uint GetUInt32Property(Property property)

Parameters

property Property

Property.

Returns

uint

Value.

GetVariable(IntPtr, Variable, Type)

Get instance variable as given type.

public static object? GetVariable(IntPtr obj, Variable ivar, Type targetType)

Parameters

obj nint

Handle of instance.

ivar Variable

Descriptor of instance variable.

targetType Type

Type of value of instance variable.

Returns

object

Value of variable.

GetVariable<T>(Variable)

Get instance variable as given type.

public T GetVariable<T>(Variable ivar)

Parameters

ivar Variable

Descriptor of instance variable.

Returns

T

Value of variable.

Type Parameters

T

Type of variable.

GetVariable<T>(IntPtr, Variable)

Get instance variable as given type.

public static T GetVariable<T>(IntPtr obj, Variable ivar)

Parameters

obj nint

Handle of instance.

ivar Variable

Descriptor of instance variable.

Returns

T

Value of variable.

Type Parameters

T

Type of variable.

Initialize(IntPtr)

Call default initializer (init) without parameter.

public static IntPtr Initialize(IntPtr obj)

Parameters

obj nint

Handle of uninitialized instance.

Returns

nint

Handle of initialized instance.

OnRelease()

Called to release instance.

protected virtual void OnRelease()

Release()

Release the instance.

public void Release()

Release(IntPtr)

Release the instance.

public static void Release(IntPtr obj)

Parameters

obj nint

Handle of instance.

Retain(Type, IntPtr)

Retain the instance.

public static NSObject? Retain(Type type, IntPtr handle)

Parameters

type Type

Type of instance.

handle nint

Handle of instance to retain.

Returns

NSObject

Retained instance, or Null if handle is Zero.

Retain<T>()

Retain the instance.

public T Retain<T>() where T : NSObject

Returns

T

Retained instance.

Type Parameters

T

Type of instance.

Retain<T>(IntPtr)

Retain the instance.

public static T? Retain<T>(IntPtr handle) where T : NSObject

Parameters

handle nint

Handle of instance to retain.

Returns

T

Retained instance, or Null if handle is Zero.

Type Parameters

T

Type of instance.

SendMessage(Selector)

Send message to instance.

public void SendMessage(Selector selector)

Parameters

selector Selector

Selector.

SendMessage(Selector, object?)

Send message to instance.

public void SendMessage(Selector selector, object? arg)

Parameters

selector Selector

Selector.

arg object

Argument.

SendMessage(Selector, params object?[])

Send message to instance.

public void SendMessage(Selector selector, params object?[] args)

Parameters

selector Selector

Selector.

args object[]

Arguments.

SendMessage(IntPtr, Selector)

Send message to instance.

public static void SendMessage(IntPtr obj, Selector selector)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

SendMessage(IntPtr, Selector, object?)

Send message to instance.

public static void SendMessage(IntPtr obj, Selector selector, object? arg)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

arg object

Argument.

SendMessage(IntPtr, Selector, params object?[])

Send message to instance.

public static void SendMessage(IntPtr obj, Selector selector, params object?[] args)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

args object[]

Arguments.

SendMessageToSuper(Selector)

Send message to super class of instance.

public void SendMessageToSuper(Selector selector)

Parameters

selector Selector

Selector.

SendMessageToSuper(Selector, object?)

Send message to super class of instance.

public void SendMessageToSuper(Selector selector, object? arg)

Parameters

selector Selector

Selector.

arg object

Argument.

SendMessageToSuper(Selector, params object?[])

Send message to super class of instance.

public void SendMessageToSuper(Selector selector, params object?[] args)

Parameters

selector Selector

Selector.

args object[]

Arguments.

SendMessageToSuper(IntPtr, Selector)

Send message to super class of instance.

public static void SendMessageToSuper(IntPtr obj, Selector selector)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

SendMessageToSuper(IntPtr, Selector, object?)

Send message to super class of instance.

public static void SendMessageToSuper(IntPtr obj, Selector selector, object? arg)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

arg object

Argument.

SendMessageToSuper(IntPtr, Selector, params object?[])

Send message to super class of instance.

public static void SendMessageToSuper(IntPtr obj, Selector selector, params object?[] args)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

args object[]

Arguments.

SendMessageToSuper<T>(Selector)

Send message to super class of instance.

public T SendMessageToSuper<T>(Selector selector)

Parameters

selector Selector

Selector.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessageToSuper<T>(Selector, params object?[])

Send message to super class of instance.

public T SendMessageToSuper<T>(Selector selector, params object?[] args)

Parameters

selector Selector

Selector.

args object[]

Arguments.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessageToSuper<T>(IntPtr, Selector)

Send message to super class of instance.

public static T SendMessageToSuper<T>(IntPtr obj, Selector selector)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessageToSuper<T>(IntPtr, Selector, params object?[])

Send message to super class of instance.

public static T SendMessageToSuper<T>(IntPtr obj, Selector selector, params object?[] args)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

args object[]

Arguments.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessage<T>(Selector)

Send message to instance.

public T SendMessage<T>(Selector selector)

Parameters

selector Selector

Selector.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessage<T>(Selector, params object?[])

Send message to instance.

public T SendMessage<T>(Selector selector, params object?[] args)

Parameters

selector Selector

Selector.

args object[]

Arguments.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessage<T>(IntPtr, Selector)

Send message to instance.

public static T SendMessage<T>(IntPtr obj, Selector selector)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SendMessage<T>(IntPtr, Selector, params object?[])

Send message to instance.

public static T SendMessage<T>(IntPtr obj, Selector selector, params object?[] args)

Parameters

obj nint

Handle of instance.

selector Selector

Selector.

args object[]

Arguments.

Returns

T

Result.

Type Parameters

T

Type of returned value.

SetProperty(Property, NSObject?)

Set value of property.

public void SetProperty(Property property, NSObject? value)

Parameters

property Property

Property.

value NSObject

Value.

SetProperty(Property, bool)

Set value of property.

public void SetProperty(Property property, bool value)

Parameters

property Property

Property.

value bool

Value.

SetProperty(Property, double)

Set value of property.

public void SetProperty(Property property, double value)

Parameters

property Property

Property.

value double

Value.

SetProperty(Property, int)

Set value of property.

public void SetProperty(Property property, int value)

Parameters

property Property

Property.

value int

Value.

SetProperty(Property, nint)

Set value of property.

public void SetProperty(Property property, nint value)

Parameters

property Property

Property.

value nint

Value.

SetProperty(Property, float)

Set value of property.

public void SetProperty(Property property, float value)

Parameters

property Property

Property.

value float

Value.

SetProperty(Property, uint)

Set value of property.

public void SetProperty(Property property, uint value)

Parameters

property Property

Property.

value uint

Value.

SetProperty<T>(Property, T?)

Set value of property.

public void SetProperty<T>(Property property, T? value)

Parameters

property Property

Property.

value T

Value.

Type Parameters

T

Type of property.

SetVariable(Variable, object?)

Set instance variable.

public void SetVariable(Variable ivar, object? value)

Parameters

ivar Variable

Instance variable.

value object

Value.

SetVariable(IntPtr, Variable, object?)

Set instance variable.

public static void SetVariable(IntPtr obj, Variable ivar, object? value)

Parameters

obj nint

Handle of instance.

ivar Variable

Instance variable.

value object

Value.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

VerifyClass(Class)

Throw ArgumentException if the class of this instance is not assignable to given class.

protected void VerifyClass(Class cls)

Parameters

cls Class

Given class.

VerifyReleased()

Throw ObjectDisposedException if instance has been released.

protected void VerifyReleased()

Operators

operator ==(NSObject?, NSObject?)

Equality operator.

public static bool operator ==(NSObject? l, NSObject? r)

Parameters

l NSObject
r NSObject

Returns

bool

operator !=(NSObject?, NSObject?)

Inequality operator.

public static bool operator !=(NSObject? l, NSObject? r)

Parameters

l NSObject
r NSObject

Returns

bool