RegisterAttribute Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Used to register a class to the Objective-C runtime.
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class RegisterAttribute : Attribute
type RegisterAttribute = class
inherit Attribute
- Inheritance
-
RegisterAttribute
- Attributes
While all classes derived from the 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 available on the iOS designer, you need to annotate those classes with the Register attribute.
// 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 {}
// 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) {}
}
Register |
|
Register |
Used to specify how the ECMA class is exposed as an Objective-C class. |
Register |
Used to specify how the ECMA class is exposed as an Objective-C class. |
Is |
Specifies whether the class being registered is wrapping an existing Objective-C class, or if it's a new class. |
Name |
The name used to expose the class. |
Skip |