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) Introduction to Objective-C Inheritance

What is the subclass of Gem

@class Gem; @interface Gem: NSObject, @property (nonatomic, strong) Gem, ruby;

6 Answers

Stone Preston
Stone Preston
42,016 Points

maddy kramer. you just need to create a class called Ruby that is a subclass of Gem. here is a general form of doing that:

@interface Classname : Superclassname
@end

now the challenge says the class name is Ruby and its super class should be Gem

Stone Preston
Stone Preston
42,016 Points

can you make it a bit more clear what your question is or what task you are having trouble with? looking at your current question you have a syntax error in your property and its also of the wrong type:

 @property (nonatomic, strong) Gem, ruby;

needs to be

@property (nonatomic, strong)  Ruby *ruby;
Brenden Konnagan
Brenden Konnagan
16,858 Points

If you are curious about what class Gem is a subclass of... the answer lies in the header file. @interface Gem: xxxx this tells you what the class is inheriting from.

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'.

I'm trying to figure it out but I have no idea what is the answer!

Maddy

Brenden Konnagan
Brenden Konnagan
16,858 Points

Follow the example of Gem... It is a subclass of NSObject. Notice how it is defined and follow that as a pattern. ;-)

Is this the answer? @interface Gem: NSObject @property (nonatomic, assign) NSNumber *Ruby; @end