ModelAttribute Class

Definition

Flag a class as a model.

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface)]
public sealed class ModelAttribute : Attribute
type ModelAttribute = class
    inherit Attribute
Inheritance
ModelAttribute
Attributes

Remarks

Objective-C protocols are like interfaces, but they support optional methods, that is, not all of the methods need to be implemented for the protocol to work.

There are two ways of implementing a model, you can either implement it manually or use the existing strongly typed definitions.

MonoTouch provides already strongly typed declarations ready to use that do not require manual binding. To support this programming model, the MonoTouch runtime supports the [Model] attribute on a class declaration. This informs the runtime that it should not wire up all the methods in the class, unless the method is explicitly implemented.

The Model attribute is applied to a class that can have optional methods, and it is typically used for declaring Objective-C delegates or data models that have a number of optional methods. The MonoTouch runtime treats classes with the Model attribute applied specially: only when a user overrides methods in a class, is the actual override exposed to the Objective-C world as existing.

This attribute is used in all of the models and delegate classes to allow the user to only implement the methods that he is interested in.

Constructors

ModelAttribute()

Default constructor.

Properties

AutoGeneratedName

Specifies if the Objective-C type name for the model should be automatically generated (and unique).

Name

Specifies if the Objective-C type name for the model.

Applies to