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 Objective-C Syntax and @property

Still waiting for the right answer and explanation. Can someone help?

@interface Product : NSObject { int _qty; }

  • (int) _______;
  • (void) ________ : (int) qty;

@end

There's not enough information at this point to know how to define the answer. Should there be underscores? No? No idea. Please help?

3 Answers

Stone Preston
Stone Preston
42,016 Points

the quiz wants you to define a getter and setter method for the _qty instance variable.

getter and setter methods dont use underscores in their names (they just use the name of the ivar without the _). If I had an integer instance variable named _someVar the getter method definition would be

-(int)someVar;

and the setter method definition would be

-(void)setSomeVar:(int)var;

does that clear things up?

It does! Thanks very much. The syntax is tripping me up real bad on these lessons. I appreciate it.

Stone Preston
Stone Preston
42,016 Points

yeah objective-C syntax is very confusing compared to other languages.

try Swift

It's next on the list!