OC property 属性设置解释
This link has the break down
http://clang.llvm.org/docs/AutomaticReferenceCounting.html#ownership.spelling.property
assign implies __unsafe_unretained ownership.
copy implies __strong ownership, as well as the usual behavior of copy
semantics on the setter.retain implies __strong ownership.
strong implies __strong ownership.
unsafe_unretained implies __unsafe_unretained ownership.
weak implies __weak ownership.
具体可参考狮子书 XD
一般实践:
delegate -> weak
IBOutLet -> weak
int, BOOL -> assign
copy 有点特殊,主要针对NSString
1.定义NSString的指针,当源字符串是NSString时,不管是copy还是string都是浅拷贝。
2.定义NSString的指针,当源字符串是NSMutableString时,strong是浅拷贝,而copy是深拷贝。这样,当有人从NSMutableString那边修改时,用了copy的NSString因为是深拷贝,就不会被影响,而strong的话就会发现明明是NSString却被改变了,所以建议使用copy。