"Database Foundations" was retired on March 22, 2017. You are now viewing the recommended replacement.

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) Foundation Framework NSNumber

Why didn't %@ print out the address that the pointer hold? Don't we need to dereference the pointer before we print it ?

Hi, I came from a C++ background. When ever we want to print out the value that the pointer is pointer to. We have to dereference it with * . In the video, Dough code is :

NSNumber * PI = @3.14; NSLog(@" PI %@", PI);

So, is there no dereferencing in Objective-C. Am I missing something here ?

1 Answer

Jarrod Taylor
Jarrod Taylor
25,619 Points

I think you're looking for & instead of @. &variableName will give you the address and @variableName will give you the description.

NSLog(@"%p", &myVar) will give you the address.

The %@ formatter is used to print the object description and the %p formatter is used for pointers.