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 trialOmar Ghias
1,837 PointsHow do you create a variable of type "id"?
I thought variable types includes array, dictionary, float, etc. and that "id" was used in the "for" method. How do I declare a variable w/ type being "id"???
4 Answers
Stone Preston
42,016 Pointsid thing = nil;
you dont use the * since variables of type id are already pointers.
William Baker
2,485 PointsIt is the same as the other types, so just replace where you would put an int or float with id.
Omar Ghias
1,837 PointsI tried "id *thing = @"nil"" but it doesn't work.. Still a bit confused.
William Baker
2,485 PointsYou are setting the NSString "Nil". What you need to do is set nothing or = nil;
*Listen to Stone :)
Omar Ghias
1,837 PointsThanks guys, help was appreciated.