static NSString usage vs. inline NSString constants

前端 未结 6 625
独厮守ぢ
独厮守ぢ 2021-01-30 09:03

In Objective-C, my understanding is that the directive @\"foo\" defines a constant NSString. If I use @\"foo\" in multiple places, the same immutable NSString object is referenc

6条回答
  •  走了就别回头了
    2021-01-30 09:23

    You should make the static variable const.

    One difference between static variable and a macro is that macros don't play well with debuggers. Macros also aren't type-safe.

    Much of the static-var-vs-macro advice for C and C++ applies to Obj-C.

提交回复
热议问题