否则weak引用为野指针,会出现问题
这里说strong 有copy的功能是错误的哦。实验例子
@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);
输出结果:
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 和 copy 讨论,有建议的的童鞋请留言
原文地址:http://blog.csdn.net/u011374880/article/details/42463037