To summarize my understanding:
Strong weak is an arc introduced, strong is equivalent to retain, but for some types, such as NSString, the use of strong is equivalent to using the copy
So directly with strong can directly deal with the situation of retain and strong.
Weak is equivalent to assign, but a bit more than the latter: when the object is killed, the weak reference is set to nil, and no message to nil causes a crash
Otherwise the weak is referenced as a wild pointer and there is a problem
Here it is said that strong has copy function is wrong oh. Experimental examples
@interface Appdelegate:uiresponder <UIApplicationDelegate>
{
NSString *retainstr;
NSString *copstr;
NSString *strongstr;
}
@property (Retain, nonatomic) NSString *retainstr;
@property (Strong, nonatomic) NSString *strongstr;
@property (copy, nonatomic) NSString *copstr;
@end
nsmutablestring *newstr = [nsmutablestring stringwithformat:@ "ABCD"];
Self.retainstr = Newstr;
Self.strongstr = Newstr;
Self.copstr = Newstr;
[Newstr appendstring:@ "123"];
NSLog (@ "Retain sting:%@", self.retainstr);
NSLog (@ "Strong string:%@", SELF.STRONGSTR);
NSLog (@ "Copy string:%@", SELF.COPSTR);
Output Result:
2014-05-02 13:31:17.660 testmultiplethreaddownload[552:60b] retain sting:abcd123
2014-05-02 13:31:17.662 testmultiplethreaddownload[552:60b] Strong string:abcd123
2014-05-02 13:31:17.663 testmultiplethreaddownload[552:60b] Copy STRING:ABCD
Retain strong and copy discussion, there are recommended children's shoes please leave a message