Class Class Class


Managed representation for an Objective-C class.

public class Class : ObjCRuntime.INativeObject
type Class = class
    interface INativeObject


You can use the Handle family of methods to turn either types-by-name or .NET types that subclass NSObject into a Class instance.

// If you know that the type subclasses NSObject, 
// you can just call new Class (Type):

Class GetClassForType (Type type) { return new Class (type); }

The following example shows how you can use the native handle to check whether the type subclasses NSObject, and thus whether obtaining an Objective-C class from a Type instance is valid:

// Using low-level handles, allows for error checking in case the 
// type does not subclass NSObject:
Class GetClassForType (Type type)
    Type typeToLookup = typeof (type);
    IntPtr myClassHandle = Class.GetHandle (typeToLookup);
    if (myClassHandle != IntPtr.Zero)
        return new Class (myClassHandle);
        return null;


Class(IntPtr) Class(IntPtr)

Creates an instance from an unmanaged handle.

Class(String) Class(String)

Creates a class from a name.

Class(Type) Class(Type)

Creates a class from the specified Type.

Class(IntPtr, Boolean) Class(IntPtr, Boolean)

Creates an instance from an unmanaged handle.


ThrowOnInitFailure ThrowOnInitFailure

Determines whether Xamarin.iOS will check in the NSObject constructor if the corresponding native object was successfully created (the default value is true).


Handle Handle

Handle (pointer) to the unmanaged object representation.

Name Name

The Objective-C name for this class.

SuperClass SuperClass

The Objective-C handle to the super class for this class.


GetHandle(String) GetHandle(String)

Returns the unmanaged handle to the Objective-C Class.

GetHandle(Type) GetHandle(Type)

Gets the Objective-C handle of the given type.

GetHandleIntrinsic(String) GetHandleIntrinsic(String)

Gets the Objective-C handle to the given type.

Lookup(Class) Lookup(Class)

This method looks up the managed type for a given Objective-C class.

Applies to