Objective-C constants: NSString comparison using ==?

后端 未结 3 1696
时光取名叫无心
时光取名叫无心 2021-01-14 00:03

The discussions I found about setting NSString constants made me code it the following way:

.h file:

extern NSString * const kSectionHeaders;
         


        
3条回答
  •  太阳男子
    2021-01-14 00:34

    == does pointer comparison, it won't compare the values of two objects. isEqualToString: (and in general isEqual:) is the right way to do this - where was it described as a "bad solution"?

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题