Swift stack and heap understanding

后端 未结 2 1882
我寻月下人不归
我寻月下人不归 2020-12-07 13:16

I want to understand what is stored in the stack and heap in swift. I have a rough estimation: Everything that you print and the memory address appears not the values, those

2条回答
  •  没有蜡笔的小新
    2020-12-07 14:05

    Classes (reference types) are allocated in the heap, value types (like Struct, String, Int, Bool, etc) live in the stack. See this topic for more detailed answers: Why Choose Struct Over Class?

提交回复
热议问题