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 trialPaul Hennig
1,596 PointsAssign an NSNumber literal with a value of '4' to the variable 'thing'.
NSArray *thing = @[4];
4 Answers
Tyler Hall
Courses Plus Student 933 PointsI know this is about a month old and didn't see an answer to this question here as I myself was stumped by this for a bit but anyways for this particular exercise I found that since the variable "thing" is declared as an "id" you can assign any value to it. Since it was declared you don't have to declare it again as was shown above. Just assign a the literal value to the variable.
id thing = nil;
thing = @4;
Sebastian Döll
24,464 PointsHere you find good advice: http://clang.llvm.org/docs/ObjectiveCLiterals.html
NSNumber *thing = @4;
Paul Hennig
1,596 PointsThe error I got:
Make sure you are assigning a NSNumber literal, and check your syntax!
I am confused about literal...
Arturo Briones
948 PointsHi, I find this solution.
id thing = nil; thing = [[NSNumber alloc] initWithInt:4];
Greetings.