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
Atiba Boswell
9,960 PointsHelp with Inheritance Code Challenge Part 3
Part 3 reads: Finally, we have a class named 'Bling' which needs to have a property called 'ruby'. Switch over to 'Bling.h' and add a property named 'ruby' that belongs to the class 'Ruby'.
I keep getting the error: "The 'ruby' property isn't quite right. Check your syntax and try again."
Can someone explain the correct syntax
9 Answers
Stone Preston
42,016 Pointsyou have
@property(nonatomic, strong) ruby *Ruby
which is almost right.
The challenge states "we have a class named 'Bling' which needs to have a property called 'ruby'. Switch over to 'Bling.h' and add a property named 'ruby' that belongs to the class 'Ruby'."
Property definitions take the form of
@property(attributes) Classname *variable;
so you need to have
@property(nonatomic, strong) Ruby *ruby;
Atiba Boswell
9,960 PointsThanks for being patient with my inexperience, i feel like i have a lot of dumb questions and am trying to rewatch videos and figure it out myself before asking.
But learning from others in this forum seems like the fastest/best result
Stone Preston
42,016 Pointsdid you get it yet? did you paste it into the right class?
Atiba Boswell
9,960 PointsNo, error still reads: "The 'ruby' property isn't quite right. Check your syntax and try again."
I pasted it into Bling.h and the code reads:
@interface Bling : NSObject
@property(nonatomic, strong) Ruby *ruby
@end
Have you done this code challenge? It's in Introduction to Objective C, Inheritance..if you want to see for yourself
Stone Preston
42,016 Pointsadd a semicolon
@property(nonatomic, strong) Ruby *ruby;
Atiba Boswell
9,960 Pointswow, sorry I just redid it and it worked fine. I think I was just missing a ; or some similar small syntax error
Atiba Boswell
9,960 PointsStep 1 of the challenge reads: "Let's create a base class called 'Gem'. In 'Gem.h' define a class named 'Gem' which is a subclass of 'NSObject'."
Correct answer for step 1: @interface Gem : NSObject
@end
Step 2: "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'."
Correct answer for step 2: @interface Ruby : Gem
@end
Step 3: "we have a class named 'Bling' which needs to have a property called 'ruby'. Switch over to 'Bling.h' and add a property named 'ruby' that belongs to the class 'Ruby'."
This code is already in Bling.h: @interface Bling : NSObject
@end
I added the @property and my code looks like: @interface Bling : NSObject
@property(nonatomic, strong) Ruby *ruby
@end
The error reads: "The 'ruby' property isn't quite right. Check your syntax and try again."
**ignore my comment "a new error appears: Don't forget to add '@end' and make sure 'Ruby' subclasses 'Gem'."...i pasted the code into the Ruby.h file instead of the Bling.h file
Stone Preston
42,016 Pointscan you post your code please?
Atiba Boswell
9,960 Points@interface Bling : NSObject
@property(nonatomic, strong) ruby *Ruby
@end
I have tried many different code, but really just guessing a lot, and would like to understand the syntax/structure of properties.
Atiba Boswell
9,960 PointsThanks for explaining the difference between Classname and variable.
When I change the code a new error appears: Don't forget to add '@end' and make sure 'Ruby' subclasses 'Gem'.
Can you explain the use of @end?
Stone Preston
42,016 Points@end marks the end of the interface of the class. it goes at the end of your header file. Just like your .m file has @end at the end of its file as well to mark the end of the implementation of your class.
Did you subclass gem in the header file of your gem class? it may have been an earlier part of the challenge
Atiba Boswell
9,960 PointsThanks for all the help Stone.
I started this track because a friend said leaning C would be the best starting point to understand programming.
I see you have completed a ton of ios, ruby and php lessons, any advice on what to learn next?
I'm at a very beginner level. I used to play online poker full time, currently work retail 9-5 and would love to transition to web design or development with poker as a side income.
Stone Preston
42,016 PointsWell your friend is right. C is a good place to start. However Objective C is not C, and can be quite intimidating to the beginner programmer. I recommend starting with javascript, then php, and then do objective C if you want to develop iOS apps. If you would rather stick to web development, I would do rails instead of objective C.
Having done both, I had a lot more fun doing the objective C course than I did rails. You run into a lot of problems with the rails videos and its pretty complicated.
You should start with the Introduction to programming course and move on down the javascript track from there.
Stone Preston
42,016 Pointsalso when I say objective C is not C...technically it is a subset of the C language, but they are really completely different beasts. Objective C has complicated syntax, is very object oriented, and revolves around concepts that can be difficult to understand.
Atiba Boswell
9,960 PointsThanks for the advice. I finished Intro to Programming and 2/3 into javascript foundations. I'll be sure to finish all the javascript lessons before getting to much further into Objective C.
Are you a developer full-time, or just learning skills on the side? I'm interested to hear a little about the day to day experience of a web developer, and the highest in demand skills for the current job market.
Stone Preston
42,016 Pointsim a student just learning skills on the side. cant really tell you anything about the industry sorry : (
Jo Albright
5,199 PointsHi Atiba,
Stone is correct in pointing you towards PHP & Javascript. Those are great beginner level web developer positions that will allow you to get into a dev job easier than trying to enter as an iOS developer. Note : most iOS developer positions require at least one well built app living on the app store.
You can either choose to be a well rounded developer who builds both server side code (PHP or Rails) and client side code (Javascript)... or you can choose to pursue being a single focus as front end (client / JS) or backend (server / PHP) dev. You can always pursue one language to get into a developer position and continue to build your language knowledge as you go.
It is much easier to learn languages when you have real life projects you are working on to help push you to find solutions to problems that arise. So try to come up with project ideas that you might enjoy building as a side project that will help you learn the language you choose to pursue. You could always try to build a poker app using PHP & Javascript.
When I started developing so many years ago, I started as a PHP developer. I then learned Actionscript (for Flash when it was still alive), Javascript, a few other languages, and I am now building iOS apps. Half of the languages I learned were because projects required me to leaner them. Objective - C was the only language that I pursued before I needed to learn it.
Hope this was helpful.
Thanks, Jo
Atiba Boswell
9,960 PointsThanks Jo, that was extremely helpful.
I will def start working on a real world project, and a poker app sounds like a great start.
Taylor Hammons
1,609 PointsTaylor Hammons
1,609 PointsWhy is "strong" added in the parentheses? None of the videos used such an example and it is not explained in any of the videos?