The word retain in the property means that the accessor (setter) generated in the @synthesize will retain the object passed in. If you do not specify 'retain' then the accessor will use 'assign'. For most
objects the passed in value is retained (old value released and new value retained). Primitive types like float and int are not objects, so the setter assigns rather than retains the value. The third option is copy, and is not used in the example.
typical retain setters
Code:
-(void)setName:(NSString *)newName
{
[newName retain];
[name release];
name = newName;
}
or
Code:
-(void)setName:(NSString *)newName
{
[name autorelease];
name = [newName retain];
}
A typical 'assign'
Code:
-(void)setAmount:(float)newAmount
{
amount = newAmount;
}
By default the accessors are atomic, they can't be called from two places simultaneously. (a lock is applied) This prevents potential garbage from being produced. nonatomic is faster than atomic since there is no locking/unlocking, and can be used if there is no expectation that there will be simultaneous calls to the same accessor.
Bob