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 trialWren Howell
3,582 PointsLet's create a base class called 'Gem'. In 'Gem.h' define a class named 'Gem' which is a subclass of 'NSObject'.
What is wrong with my code @property(nonatomic, strong) Ruby*ruby. It says did you declare a variable called Ruby?
10 Answers
Stone Preston
42,016 Pointslooks like you forgot a semicolon after your property declaration:
@property(nonatomic, strong) Ruby*ruby;
it also unconventional not to put a space between the class name and the *.
@property(nonatomic, strong) Ruby *ruby;
is a more conventional pointer declaration
Wren Howell
3,582 PointsI still get Bummer! Did you declare the 'Ruby' interface in 'Ruby.h'? I dont do anything to the Gem.h file right?
Stone Preston
42,016 Pointsare you on task 3? which task are you on
Wren Howell
3,582 Pointstask 2
Stone Preston
42,016 Pointsyou need to switch to Ruby.h. task 2 states: Now let's define a subclass of Gem named Ruby. Switch over to 'Ruby.h' and create a class named 'Ruby' which is a subclass of 'Gem'.
class definitions generally look like this:
@interface ClassName : SuperClass
@end
so for your Ruby class, the classname is Ruby and it needs to inherit from your Gem class.
Wren Howell
3,582 Pointsso @interface Ruby *ruby?
or is it @interface Ruby: Gem?
Wren Howell
3,582 Pointsnever mind got it
Wren Howell
3,582 Pointswhat about part three? I am confused about inheritance
Stone Preston
42,016 Pointsyou need to switch to Bling.h and add a property of the class Ruby named ruby. you had it in your original post
@property(nonatomic, strong) Ruby *ruby;
Wren Howell
3,582 Pointsbecause I thought we enter @property (strong, nonatomic) Ruby*ruby;
Stone Preston
42,016 Pointsyes. enter that in bling.h
@interface Bling : NSObject
@property (strong, nonatomic) Ruby*ruby;
@end
Wren Howell
3,582 PointsThank you so much!
Chase Snow
32,932 Points@Stone Preston This was incredibly helpful for me as well, Thank you!