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

Wren Howell
Wren Howell
3,582 Points

Let'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
Stone Preston
42,016 Points

looks 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
Wren Howell
3,582 Points

I still get Bummer! Did you declare the 'Ruby' interface in 'Ruby.h'? I dont do anything to the Gem.h file right?

Stone Preston
Stone Preston
42,016 Points

are you on task 3? which task are you on

Stone Preston
Stone Preston
42,016 Points

you 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
Wren Howell
3,582 Points

so @interface Ruby *ruby?

or is it @interface Ruby: Gem?

Wren Howell
Wren Howell
3,582 Points

what about part three? I am confused about inheritance

Stone Preston
Stone Preston
42,016 Points

you 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
Wren Howell
3,582 Points

because I thought we enter @property (strong, nonatomic) Ruby*ruby;

Stone Preston
Stone Preston
42,016 Points

yes. enter that in bling.h

@interface Bling : NSObject

@property (strong, nonatomic) Ruby*ruby;

@end
Chase Snow
Chase Snow
32,932 Points

@Stone Preston This was incredibly helpful for me as well, Thank you!