关于二者实际应用中的详细区别,可查看:http://blog.csdn.net/q199109106q/article/details/8565017
代码示例:
NSString *string = @"zhongguo";
textField1 = [[UITextField alloc] init];
textField1.frame = CGRectMake(10, 100, 100, 50);
[self.view addSubview:textField1];
textField2 = [[UITextField alloc] init];
textField2.frame = CGRectMake(10, 200, 100, 50);
[self.view addSubview:textField2];
//strong
textField1.text = string;
NSString *name1 = textField1.text;
NSLog(@"textField1 ---> %@",textField1.text);//textField1 ---> zhongguo
NSLog(@"name1 ---> %@",name1);//name1 ---> zhongguo
textField1.text = @"textField1 ---> 01";
NSLog(@"textField1 ---> %@",textField1.text);//textField1 ---> textField1 ---> 01
NSLog(@"name1 ---> %@",name1);//name1 ---> zhongguo
name1 = @"name1 ---> 01";
NSLog(@"textField1 ---> %@",textField1.text);//textField1 ---> textField1 ---> 01
NSLog(@"name1 ---> %@",name1);//name1 ---> name1 ---> 01
NSLog(@" ");
//weak
textField2.text = string;
__weak NSString *name2 = textField2.text;
NSLog(@"textField2 ---> %@",textField2.text);//textField2 ---> zhongguo
NSLog(@"name2 ---> %@",name2);//name2 ---> (null)
textField2.text = @"textField2 ---> 01";
NSLog(@"textField2 ---> %@",textField2.text);//textField2 ---> textField2 ---> 01
NSLog(@"name2 ---> %@",name2);//name2 ---> (null)