Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Objective-C Basics (Retired) Advanced Objective-C Dynamic Typing

Swapnil Kapse
Swapnil Kapse
1,162 Points

Assign an NSNumber literal with a value of '4' to the variable 'thing'. How to solve this?

How to code

Assign an NSNumber literal with a value of '4' to the variable 'thing'. Even though, sentence is written as 'NSNumber *thing = @4;' I am getting error as in earlier challenge's answer is 'id thing = 4;'

Hence, thing is getting defined twice. Please suggest

2 Answers

Michael Hulet
Michael Hulet
47,843 Points

I haven't looked at the challenge, but from what I've read here, it sounds like all you'd need to do is reassign the thing variable to an NSNumber literal of 4, like this:

thing = @4;

NSNumber (literal) example:

NSNumber *numberEight = @8;
Swapnil Kapse
Swapnil Kapse
1,162 Points

Even though, sentence is written as 'NSNumber *thing = @4;' I am getting error as earlier challenge's answer is 'id thing = 4;'

thing is getting defined twice. Please suggest