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 trialGarrett Kucinski
11,955 PointsCan someone explain the syntax of creating a property please? (stuck on inheritance challenge)
I'm lost on the whole getter/setter and property syntax, not sure what I'm writing. So I'm stuck on the inheritance challenge because it keeps asking me to check my syntax because I don't understand it.
@interface Bling : NSObject
@property Ruby* ruby;
@end
3 Answers
Dave Thomas
2,555 PointsYou don't have to, it will just default to atomic which is a multi-threaded var (which is beyond the scope of my ability at this point), but that is a specialized thing I guess. The strong vs. weak has to do with automatic reference counting and memory. It's best to declare those based on the parent/child relationship. Sorry about the Ruby, didn't know you had created your own custom class... ;)
Dave Thomas
2,555 Pointsyour format is a bit off...
@interface Bling : NSObject
@property (nonatomic, strong) NSString *ruby;
@end
--
you have to tell the compiler what type of data it is, in this case I'm guessing a string thus NSString *stringName, also you will learn more about nonatomic and weak vs. strong as you go...
Garrett Kucinski
11,955 PointsThanks Dave that really helped,
It actually was supposed to be
@property(nonatomic, strong) Ruby *ruby;
I have another question, do you always have to say whether it's nonatomic or not?
I thought they were atomic by default so should you just be able to type...
@property Ruby *ruby;