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 trialZhuhua MO
1,650 PointsDeclare a variable named thing of type id and initialize it to nil. I can't find my way out, can someone help? Thanks.
I type:
id thing = @"nil";
It runs well in my Xcode, but the challenge keeps telling me to declare the variable 'thing' and set it to 'nil'.
2 Answers
Cody Te Awa
8,820 PointsI think nil is essentially nothing, therefore 'thing' should have no value, however you're code assigns 'thing' to a string that represents the literal 'nil'. If you were to print nil as you have it represented it would print a string literal of the word nil, however if you trying printing nil how it should be, it should return (null) meaning Nothing exists.
- Hope that helps
Zhuhua MO
1,650 PointsHi Cody, Thank you for replying. I finally found my way out after trying almost 10 different code. For those who come across the same problem, the answer is:
id thing = nil;
Thanks again Cody. :)