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

Michael Nees
Michael Nees
1,070 Points

Create a bass class

Got stuck with this question: Let's create a base class called 'Gem'. In 'Gem.h' define a class named 'Gem' which is a subclass of 'NSObject'.

Have tried: @interface Gem : NSObject; -(char)area;

What is not correct here?

10 Answers

Bill Walker
Bill Walker
5,951 Points

In your property, use

@property (nonatomic, strong) Ruby *ruby;

You could probably use other attributes as well, weak, copy, etc. strong worked for me though.

I would say the semicolon is wrong

@interface Gem : NSObject
- (char) area;
@end
Michael Nees
Michael Nees
1,070 Points

Thanks Sebastian for your message. Unfortunately it's comes back with an error message.

Bill Walker
Bill Walker
5,951 Points

You have a semicolon after NSObject, remove it.

Also make sure you have @end at the bottom of the file

Michael Nees
Michael Nees
1,070 Points

Done that too William , plus it has asked me to add @end. Any other ideas?

@interface Gem : NSObject -(char)area; @end

Bill Walker
Bill Walker
5,951 Points

I took a look at the challenge, it's not asking for you to define anything other than the class.

@interface Gem : NSObject
@end

This worked for me.

Michael Nees
Michael Nees
1,070 Points

Many thanks William... it worked! Got another small issue...

Comes back with message "check syntax on this code:

@interface Bling : NSObject @property (nonatomic) Ruby * ruby; @end

What could this be?

Cheers Michael

Michael Nees
Michael Nees
1,070 Points

Great, many thanks William! Note quite sure why I had to add "strong" (or weak or copy), but I guess I will find out more in the process.

Cheers Michael

Michael Nees
Michael Nees
1,070 Points

Great, many thanks William! Note quite sure why I had to add "strong" (or weak or copy), but I guess I will find out more in the process.

Cheers Michael

please can you tell me what is the answer for Inheritance Challenge part 2