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

Advanced Objective-C Dynamic Typing Challenge

I'm trying to learn about Dynamic typing, actually I only have this challenge left butI'm stuck on Task 2. The task is: "Assign an NSNumber literal with a value of '4' to the variable 'thing'."

and my current input (from Task 1) looks like this: "id thing = nil;"

What should I do?

2 Answers

All literals in objective-c are prefixed with the @ symbol. So a literal number 4 is represented using @4 Your code should look something like

id thing = nil;
thing = @4;

You could also use the helper construction method with NSNumber like:

id thing = nil;
thing = [NSNumber numberWithInt:4];

Thank you!! I had tried "thing = 4". I had forgotten about the @. Thank You!!!!!