Upravit

Sdílet prostřednictvím


Class Class

Definition

Managed representation for an Objective-C class.

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

Remarks

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

Constructors

Class(IntPtr, Boolean)

Creates an instance from an unmanaged handle.

Class(IntPtr)

Creates an instance from an unmanaged handle.

Class(String)

Creates a class from a name.

Class(Type)

Creates a class from the specified Type.

Fields

ThrowOnInitFailure

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

Properties

Handle

Handle (pointer) to the unmanaged object representation.

Name

The Objective-C name for this class.

SuperClass

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

Methods

GetHandle(String)

Returns the unmanaged handle to the Objective-C Class.

GetHandle(Type)

Gets the Objective-C handle of the given type.

GetHandleIntrinsic(String)

Gets the Objective-C handle to the given type.

Lookup(Class)

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

Applies to