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) Introduction to Objective-C From Structs to Objects

Pointers

Hi, I am still confused on why he keeps using "*". I know that it indicates a pointer but I am still not sure what a pointer is and I do not know which things in my programs are pointers. Please explain this to me. Thanks!

1 Answer

Stone Preston
Stone Preston
42,016 Points

in objective c, all objects are pointers. to create an NSArray object called someArray you would use

NSArray *someArray = [[NSArray alloc] init];

i created it using * since every object is a pointer.

A pointer just holds a memory address. So my someArray object doesnt contain the actual array itself, it contains the memory address of that array. When working with objects you dont have to dereference the pointers since thats done behind the scenes. you can just refer to the object as its name without the *, so if I wanted to refer to my array i would just use someArray