objective-c 方法值類型與引用類型傳遞

 

 

- (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";

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章