Objective C const NSString * vs NSString * const

后端 未结 2 1644
温柔的废话
温柔的废话 2020-12-22 19:18

I\'m trying to a NSString constant in my .h file to be defined in my .m. I understand that
extern NSString * const variableName; in the .h and
<

2条回答
  •  旧巷少年郎
    2020-12-22 19:30

    It's not the same. The const modifier can be applied to the value, or the pointer to the value.


    int * const
    

    A constant pointer (not modifiable) to an integer (its value can be modified)


    const int *
    

    A modifiable pointer to a constant integer (its value can't be modified)


    So you can imagine:

    const int * const;
    

提交回复
热议问题