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
Lachlan Mitchell
9,278 PointsCode Challenge: Inheritance
Hey everyone! I'm stuck on task 3 of the 'Inheritance' code challenge for 'Objective-C Basics'.
"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'."
To which I would answer in Bling.h:
@property(nonatomic) Ruby *ruby;
However, that only returns: "Bummer! Remember, 'ruby' should be a "nonatomic" property." I have also tried completely interfacing it as the Bling class:
@interface Bling : Ruby
@property(nonatomic) Ruby *ruby;
@end
But that doesn't work either, and the question only asks for us to add the ruby property.
Any help at all would be appreciated. Thanks!
8 Answers
nemanjasreckovic
8,784 PointsI got same error but when I add strong param too, it worked
@property(nonatomic, strong) Ruby *ruby;
Mike Croft
7,463 PointsI'm getting the same error, I assume its an error on their side :S
Lachlan Mitchell
9,278 PointsAwesome, thanks for the confirmation! I guess we'll just wait for a fix :)
Jonathan Scheel
5,531 PointsWas nonatomic and/or strong ever discussed as what those are and why they are there/when they are used? If so, could you point me to the video? I never saw it.
Joseph Lau
5,420 Pointsnope, me neither.
Meshal Waleed
1,935 Pointsany one got this?
Meshal Waleed
1,935 Pointssolve it , this is the solution for task 3 :
#import “Ruby.h”
@interface Bling : NSObject
@property (nonatomic,strong) Ruby * ruby;
@end
Daniel Burt
3,699 PointsJust been going through this task today and was working through my errors. This was helpful but to avoid any confusion, if you include the #import "Ruby.h" element it will fail in the compiler.
Trey Chad
3,535 PointsMeshal,
Instead of using #import "Ruby.h" at the top of the Bling class, wouldn't the code below be an alternate solution?
@interface Bling : NSObject @class Ruby;
@property (nonatomic,strong) Ruby * ruby; @end
Note: How do you insert the black background when trying to show code in a forum post?
Meshal Waleed
1,935 Pointsyou can see the markdown cheetsheet team tree house provided here https://teamtreehouse.com/forum/code-challenge-inheritance#
Meshal Waleed
1,935 PointsCode Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.
Trey Chad
3,535 PointsOkay great, thanks!
Lachlan Mitchell
9,278 PointsLachlan Mitchell
9,278 PointsThat's weird, because I actually tried it with that exact syntax and it didn't work... I'll try it now. Thanks!