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

General Discussion

Basic question

I was reading the forum and have some questions about what some vocal means.

In the following line of code can someone break it down to me and tell me what it means for 'thing' to be initialized to nil.

NSNumber thing = nil;

thanks!

4 Answers

Stone Preston
Stone Preston
42,016 Points

nil is just a zero pointer value

so when would you ever use that when coding?

Stone Preston
Stone Preston
42,016 Points

well, all objects start out as nil before you give them a value, so you see it used in init methods. You also use it when you dont want an object to have a value you anymore.

someObject = nil;

You can also use it to check if an object actually has a value (if you only wanted to do something if that object wasnt empty)

if (someObject != nil)

there are many uses but these are probably the most common

Thanks!