Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Beyond the Basics Pointers: Part 2

Storing Pointers

It would be nice if the video discussed how a pointer is stored, and the different sizes of different types of pointers. I'm refreshing old skills, so please correct me if I'm wrong. It seems like passing by reference allows us to not copy large chunks of data. However, we still need to allocate memory for the pointer variable, correct?

Rodrigo Chousal
Rodrigo Chousal
16,009 Points

I don't think we need to allocate memory for a pointer variable, since it's just a pointer. The pointer doesn't have real data in it, just the memory address of a variable. Since I'm not sure, I will link Amit Bijlani to this thread.

1 Answer

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

When a function is called a stack frame or stack pointer is created which contains information like: function parameters, local variables and return types. All this information is pushed onto to the stack which is a "FILO" (first in, last out) data structure, that is managed and optimized by the CPU quite closely.