MonoTouch.ObjCRuntime.Class Class
Managed representation for an Objective-C class.

See Also: Class Members

Syntax

public class Class : INativeObject

Remarks

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

c# Example

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

c# Example

//
// 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);
    else
        return null;
}

Requirements

Namespace: MonoTouch.ObjCRuntime
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0