iOS 一个函数同时返回多个参数的策略

2015-04-15 0 744
iOS 一个函数同时返回多个参数的策略
#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

遇见资源网 objective-c iOS 一个函数同时返回多个参数的策略 http://www.ox520.com/16613.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务