Property

  • The @Property annotation facilitates the creation of Objective-C property declarations from annotated Java fields, mirroring Apple's @property functionality.

  • Default attributes like readwrite, strong (with ARC), and atomic are automatically applied and thus omitted from the annotation.

  • Strings inherently receive the copy attribute for proper memory management in Objective-C.

  • Utilizing the value method within the annotation enables developers to specify custom attributes like copy and nonatomic for fine-grained control over the generated property declaration.

  • Errors are generated during compilation if invalid attributes are included within the annotation, ensuring code correctness.

public abstract @interface Property implements Annotation

Adds property declarations to generated Objective-C for annotated fields. See Apple's @property documentation.

Notes:

  • Invalid attributes are reported as errors.
  • readwrite, strong (when using ARC), and atomic attributes are removed since they are defaults.
  • Strings will include the copy attribute.
Example:
 class Foo {
   @Property("copy, nonatomic") protected String bar;
 }
generates:
 @property (copy, nonatomic) NSString *bar;

Public Method Summary

String
value()

Inherited Method Summary

Public Methods

public String value ()