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

I am stuck with a challenge

I need to assign an NSNumber literal with a value of '4' to the variable 'thing' and this is what I have come up with and it is obviously wrong, can someone please help!

This is the code so far (the previous part was for me to assign the id "thing" to nil

Do I need to use the assign memory directive?

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

2 Answers

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Ben,

After creating the id variable, you can set it to a NSNumber literal like so.

id myVariable = nil;
myVariable = @4;

I hope this helps.

Thank you!