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 trialbusterlabs
9,276 PointsDynamic Type
Video didn't show all of the needed codes for Dynamic Type. Can't figure out the Challenge Task. Need the codes for Shape.h
8 Answers
Charlie O'Shea
18,737 PointsI don't think part 2 was ever explained in the preceding video.
Plus it's hard to follow along when files suddenly appear in the navigation that we haven't got.
Stone Preston
42,016 Pointswhat task of the challenge are you on? what code have you tried so far?
busterlabs
9,276 PointsChallenge task 1 of 3 Declare a variable named thing of type id and initialize it to nil.
Stone Preston
42,016 Pointsdeclaring a variable of type id generally looks like:
id variableName = value;
note that since id types are pointers by default, you dont use an asterix like you would regular object variables.
so to declare an id type named thing and initialize it to nil you would use:
id thing = nil;
busterlabs
9,276 PointsGot that part. It's the next 2 steps that's driving me nuts
busterlabs
9,276 PointsChallenge task 2 of 3 Assign an NSNumber literal with a value of '4' to the variable 'thing'.
Stone Preston
42,016 Pointsyou assign values to id object the same as any other. to assign a literal NSNumber you use literal syntax like so: someVariable = @x
where x is the number value you want to assign.
to assign a literal value of 4 to thing you would use:
thing = @4;
busterlabs
9,276 PointsWow! Thanks. How bout the last one? Here's what I got...
NSLog(@"thing = 4", thing);
It's saying that I got the string right but the format was wrong
Stone Preston
42,016 Pointsyou almost have it. you need to use a format specifier in place of the 4. use the %@ format specifier for object types:
NSLog(@"thing = %@", thing);
Christopher Bijalba
12,446 PointsYeah, you should put the "do this" in the actual tutorial. Also, the shape.h and shape.m files are not anything I'd built leading up to this point...