Why do we always assign Objective-C primitives?
Because we can't retain
or copy
them - that's for Objective-C objects only.
My imagination says we would be assigning intProperty a pointer to stack memory
No, not really. We are assigning an int
to it. Of course, internally, the instance variable is implemented as a pointer-to-int into the myObject
object, with some offset added (described by the instance variable layout of the class).
But if by "stack variable", you mean "objects [that's the C terminology for variables] with automatic storage duration", then no. Objective-C objects are usually allocated dynamically (maybe "on the heap", but that's really irrelevant), and live as long as they are not deallocated, i. e. until their reference count reaches zero. Then they are deallocated, destroyed, and all of their instance variables (which back the corresponding @property
es) are invalidated as well.