To reiterate, it does depend on context. In an non-ARC situation:
@property (nonatomic, copy) NSMutableArray *myArray
@property (nonatomic, copy) NSString *myString
@property (nonatomic, retain) UIColor *myColor
//Note the change to an int rather than a pointer to an int
@property (nonatomic, assign) int myInt
//Note the change to an int rather than a pointer to an int
@property (nonatomic, assign) BOOL myBOOL
The copy on myArray is to prevent modification by another "owner" of the object you set. In an ARC project, things change a bit:
@property (nonatomic, copy) NSMutableArray *myArray
@property (nonatomic, copy) NSString *myString
@property (nonatomic, strong) UIColor *myColor
//Note the change to an int rather than a pointer to an int
@property (nonatomic, assign) int myInt
//Note the change to an int rather than a pointer to an int
@property (nonatomic, assign) BOOL myBOOL
The change is primarily to myColor in your situation. You wouldn't use retain
as you aren't managing reference counting directly. The strong
keyword is a way of asserting "ownership" of the property and similar to retain
. An additional keyword is also provided, weak
, that would typically be used in place of assign for object types. Apple's common example of a weak
property is for delegates. I'd recommend going through the Transitioning to ARC Release Notes in addition to the Memory Management Guide a time or two as there is more nuance than can easily be covered in an SO post.