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

Robert Woody
Robert Woody
2,787 Points

How would declare the following instance if you didn't know which class it belongs to?

This is a quiz question within the "Designated Initializers & Convenient Constructors" section of "Building A Blog Reader App for iPhone." I am running up against a wall; perhaps it's something simple I am overlooking but can't even find a hint in my notes.

Here is the question:

How would declare the following instance if you didn't know which class it belongs to?

obj = [1,2,3,4];

3 Answers

David Langley
David Langley
10,965 Points

Hi Amit

I thought I had this one by using the - (id) but keep getting the wrong.

  • (id) obj = [1,2,3,4];

have gone through this every which way but cant get it correct, help please...

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

When declaring a variable you don't use parenthesis. The parenthesis are used only when declaring the return type to a method.

id obj =  [1,2,3,4];
David Langley
David Langley
10,965 Points

Thanks Amit ! Another quick question, when i see your answers in here they are coloured etc. When doing the code challenges and quiz mine is in black and white, and doesn't auto complete.

I am assuming that everyones is like this ? and the auto complete only works in Xcode ?

thanks.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Yes, unfortunately the autocomplete is only available in Xcode and we are working on better syntax highlighting for Code Challenges. So don't worry this is not just you this is how our site behaves for everyone.