Placement of the asterisk in Objective-C

前端 未结 14 1098
鱼传尺愫
鱼传尺愫 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:19

    There is no difference, however you should be aware that only the first "token" (so to speak) defines the type name, and the * is not part of the type name. That is to say:

    NSString *aString, bString;
    

    Creates one pointer-to-NSString, and one NSString. To get both to be pointers, do either:

    NSString *aString, *bString;
    

    or:

    NSString *aString;
    NSString *bString;
    

提交回复
热议问题