Table 2-1  Attributes for declared properties

Attribute

Effect

getter=getterName

setter=setterName

Specifies the names of getter and setter accessor methods (see “Storing and Accessing Properties”). You specify these attributes when you are implementing your own accessor methods and want to control their names.

readonly

Indicates that the property can only be read from, not written to. The compiler does not synthesize a setter accessor or allow a nonsynthesized one to be called.

readwrite

Indicates that the property can be read from and written to. This is the default if readonly is not specified.

assign

Specifies that simple assignment should be used in the implementation of the setter; this is the default. If properties are declared in a non–garbage-collected program, you must specify retain or copy for properties that are objects.

retain

Specifies that retain should be sent to the property (which must be of an object type) upon assignment. Note that retain is a no-op in a garbage-collected environment.

copy

Specifies that copy should be sent to the property (which must be of an object type) upon assignment. The object’s class must implement the NSCopying protocol.

nonatomic

Specifies that accessor methods are synthesized as nonatomic. By default, all synthesized accessor methods are atomic: A getter method is guaranteed to return a valid value, even when other threads are executing simultaneously. For a discussion of atomic versus nonatomic properties, especially with regard to performance, see “Declared Properties” in The Objective-C Programming Language.