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

Sergey Geraskov
Sergey Geraskov
3,621 Points

don't understand where is a mistake...

In challenge task I have to assign an NSNumber literal with a value of '4' to the variable 'thing'.

I have done:

  1. id thing=nil;
  2. NSNumber *thing= at4;

Where is a mistake... Please help me ...

PS. "at" cann't write in symbol here.

2 Answers

Stone Preston
Stone Preston
42,016 Points

your object is of type id, so you can just assign it an NSNumber literal like so:

id thing = nil;
thing = @4;
Sergey Geraskov
Sergey Geraskov
3,621 Points

thanks for answer)

that was a noob question...

Stone Preston
Stone Preston
42,016 Points

not at all. the dynamic typing can be a little confusing, which is why its one of the last topics covered