Q:

What attributes should I use for @property?

Is there anyway to identify when or what conditions should I use the different attributes?  I looked over the apple documentaries and it seemed quite confusing to me.  Can someone give me the definitions and some examples for them?  Thanks.

A:

Memory management attributes
retain: values are sent a retain message when the value is set. This is the attribute you'll use most often.
copy: the value is sent a copy message and the returned value is stored.
For properties that uses either retain or copy you must release the the object in dealloc otherwise the object will leak.
assign: assign simply copies the value. In the case of objects that means copying the objects address (no retain message is sent to the object). You should use this for when using retain would create a retain loop. Examples of retain loops are parent/child relationships where both objects require a reference to the other (the parent should retain the child, the child should assign the parent). An object should assign its delegates for the same reason. You must use assign for primitives values (char, int, long etc) too. retain and copy would not work with primitives because primitives are not objects.

