Foundation.RegisterAttribute Class
Used to register a class to the Objective-C runtime.

See Also: RegisterAttribute Members

Syntax

[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class RegisterAttribute : Attribute

Remarks

While all classes derived from the Foundation.NSObject class are exposed to the Objective-C world, in some cases you might want to expose the class using a different name to the runtime.

In addition, if you want your classes to be avaialble on the iOS designer, you need to annotate those classes with the Register attribute.

c# Example

// This class is never surfaced to Objective-C's runtime
class NotSurfaced {}

// This class is automatically surfaced to Objective-C's 
// runtime, since it is a subclass of NSObject, and it
// is visible by the Objective-C runtime as "AutomaticallySurfaced"
class AutomaticallySurfaced : NSObject {}

// This class is surfaced to the Objective-C runtime with
// the name 'MyName'
[Register ("MyName")]
class InternalName : NSObject {}

c# Example

// This UIView is surfaced to the iOS designer.
[Register]
public class MyView : UIView {
    public MyView (IntPtr handle) : base (handle) {}
    public MyView (CGRect rect) : base (rect) {}
}

Requirements

Namespace: Foundation
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0