Objective-C里面局部静态变量指向的常量字符串为啥不存在与cfstring节呢?

- (void)viewDidLoad {
    [super viewDidLoad];
    
    static NSString *haha = @"hehehehe";

    
    NSLog(@"static");
    // Do any additional setup after loading the view, typically from a nib.
}

如上述代码所示,很简单的iOS模版工程。局部变量、全局变量(无论是非静态)指向的常量字符串都会出现在__DATA段的CFString节里,但是用machoview或者hopper都看不到hehehe,能看到static。

环境是在DEBUG下,而且为了避免优化,还实验了__attribute__((used))来避免符号被去除。

请问有人知道吗?谢谢~

使用下haha

有个问题:

  1. 同样函数中的局部变量NSString *haha = @“hehehe”, 不使用,@"hehehe"也存在与cfstring 节中。这是为啥呢?

我看了下build setting的optimization,是-O0啊。