- #import "ViewController.h"
- @interface ViewController ()
- @end
- @implementation ViewController
- void func(__strong NSString ** str1, __strong NSString ** str2){
- NSString * strNew = @"新的内容1";
- NSString * strNew2 = @"新的内容2";
- *str1 = strNew;
- *str2 = strNew2;
- };
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- NSString * str1 = @"str1";
- NSString * str2 = @"str2";
- // 核心:传入对象引用的指针.
- func(&str1, &str2);
- NSLog(@"str1 = %@ \n str2 = %@", str1, str2);
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
来源: http://www.phpxs.com/code/1006567/