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

eric schwartz
eric schwartz
4,242 Points

composition challenge

In a code challenge, I've been trying to add a ruby (from Ruby.h) to a new class Bling. I've tried every different ordering of the following code but I keep getting an error that I'm doing something wrong with the property. Can anyone point out the error to me? Thanks, Eric

import "Ruby.h"

@interface Bling : NSObject

@property (nonatomic strong) Ruby *ruby;
ruby = [[Ruby alloc] init];

@end

2 Answers

Michael Hulet
Michael Hulet
47,913 Points

I haven't done it in a while, so my answer might be wrong, but I used to do a little iOS development, so I'll try to answer.. I'm pretty sure you need to separate the things in parentheses with commas, like this:

#import "Ruby.h"
@interface Bling : NSObject
@property (nonatomic, strong) Ruby *ruby;
ruby = [[Ruby alloc] init];
@end

''' Objective-C @class Ruby; @interface Bling : NSObject @property (nonatomic, strong) Ruby *ruby; @end '''