@property (nonatomic, copy) NSString* name;
is better, as NSString
is immutable and it's child class NSMutableString
is mutable.
As long as you are using NSString
through out, you won't see any difference. But when you start using NSMutableString
, things can get little dicey.
NSMutableString *department = [[NSMutableString alloc] initWithString:@"Maths"];
Person *p1 = [Person new];
p1.department = department;
//Here If I play with department then it's not going to affect p1 as the property was copy
//e.g.
[department appendString:@"You're in English dept."];
Had it been just retain it would have changed the department of the p1
.
So having copy is prefered in this case.