I\'m still new to Objective-C and having some difficulties trying to figure out the appropriate way to use assign, retain, copy, strong, etc. when setting a property.
F
@property (nonatomic, copy) NSMutableArray *myArray
@property (nonatomic, copy) NSString *myString
@property (nonatomic, retain) UIColor *myColor
@property (nonatomic) int myIn
@property (nonatomic) BOOL myBOOL
copy mutable objects, or objects with mutable subclasses such as NSString
: this stops them being modified by another owner. although i don't think its recommended by apple to use mutable objects as properties
other objects are generally retained, with an exception being delegates, which are assigned to prevent ownership loops
primitives like int
and BOOL
are assigned, this is the default option for @property so doesnt need to be specified, although it doesnt hurt to add it in if you feel it helps the readability