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

Dynamic Typing

The Challenge is: Assign an NSNumber literal with a value of '4' to the variable 'thing'.

I tried this code:

id thing = nil;

NSNumber *thing=4;

3 Answers

Geia soy file Gianni, To provlima einai oti exeis hdh orisei thn metavlith thing. To Code Challenge sou zitaei na oriseis mia nea metavliti typou NSNumber kai meta na doseis sto thing thn nea metavlith.

id thing = nil;
NSNumber *temp = @4;
thing = temp;

Kalh synexeia. :)

Y.G. Mporeis na vazeis ton kodika sou se ena plaisio afinontas apo mprosta 4 kena (spaces).

Hi, id thing = nil; NSNumber *thing=4;

Since you have already defined thing as a type id, you are redefining thing in the next line. I hope the code below will help.

NSNumber *thing=@4; //define things a NSNumber type and the assign it the value 4 by using the @ literal.

Euxaristw Kwnstantine, thank you Rashu !