objective-c 方法值类型与引用类型传递

2023-05-14,,

 

 

- (void)viewDidLoad

{

int testNum=10;

    NSString* testStr=@"Hi";

    GoodsBasicInfoEntity*testGBIE=[[GoodsBasicInfoEntity alloc]init];

    testGBIE.pC_Name=@"1111";

    [self testEdit: &testNum str:&testStr testGBIE:testGBIE];

    

    NSLog(@"%d,,,,,,%@,,,,,,%@",testNum,testStr,testGBIE.pC_Name);//输出:20,,,,,,hello,,,,,,how are you ?

}

-(void)testEdit:(int *)num str:(NSString**)str testGBIE:(GoodsBasicInfoEntity*)testGBIE

{

    *num=20;

    *str=@"hello";

    testGBIE.pC_Name=@"how are you ?";

    testGBIE=[[GoodsBasicInfoEntity alloc]init];

    testGBIE.pC_Name=@"123";

}

《objective-c 方法值类型与引用类型传递.doc》

下载本文的Word格式文档,以方便收藏与打印。