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) Advanced Objective-C Dynamic Typing

How to set an id variable and initialize it with a value

In the video, I saw the instructor traverse over an array using id, but not actually declaring a variable of type id.

2 Answers

It is done in exactly the same way as you would with any other variable: first write the variable type (id), then the name (thing) and finally set it to some value (nil in this case). Don't forget the semi-colon at the end.

Thank you Dino! I got it!