Placement of the asterisk in Objective-C

前端 未结 14 959
鱼传尺愫
鱼传尺愫 2020-11-27 13:34

I have just begun learning Objective-C, coming from a VB .Net and C# .Net background. I understand pointer usage, but in Objective-C examples I see the asterisk placed in s

14条回答
  •  有刺的猬
    2020-11-27 14:14

    There may not be any differences in the alternatives 1, 2 and 4 to the computer but there are to other readers of the code.

    Since explanations like https://stackoverflow.com/a/1521382 and https://stackoverflow.com/a/16040884 and https://www.tutorialspoint.com/objective_c/objective_c_pointers.htm use the first alternative:

    1. NSString *string;

    and all extra variables need their own asterisk like in:

    NSString *aString, *bString;

    my humble suggestion is that we use alternative 1 as a standard.

提交回复
热议问题