Is an Objective-C object, e.g., NSString
, placed on the stack or the heap?
The pointee of an Objective-C object is stored on the heap. But there are two exceptions: constant strings like @"foo"
and block literals are stored in the __DATA
segment (for global variables).
Normally none of ObjC objects will be stored on the stack.
They are allocated on the heap. That's true for basically all Objective-C objects, blocks being the only exception I can think of at the moment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With