OC中指针的改变和要点

直接看例子!!!
//
//  main.m
//  PointerPointer
//
//  Created by Rayln Guan on 8/30/13.
//  Copyright (c) 2013 Rayln Guan. All rights reserved.
//

#import <Foundation/Foundation.h>

void test1(NSString *str){
    str = @"567";
}
void test2(NSString **str){
    *str = @"678";
}

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        NSString *str = @"12345";
        test1(str);
        NSLog(@"str:%@", str); //打印出12345
        
        test2(&str);
        NSLog(@"&str:%@", str); //打印出678
        
    }
    return 0;
}


你可能感兴趣的:(指针)