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 Build a Simple iPhone App (iOS7) Refactoring into a Model Creating a Custom Class

Stefano Pellegrino
Stefano Pellegrino
1,379 Points

Quote implementation

What's wrong?

import "Quote.h"

@implementation Quote

  • (void) quotes { if (_quotes == nil) { _quotes = [[NSArray alloc] initWithObjects: @"asso",@"kappa", @"Jack",nil]; } }

  • (NSString *) randomQuote {

    return @"Some Quote"; }

@end

1 Answer

Dave Ko
Dave Ko
11,915 Points

Give this a try.

#import "Quote.h"

@implementation Quote

- (NSArray *) quotes { // 

if (_quotes == nil){
        _quotes = [[NSArray alloc] initWithObjects:@"Asso", "Kappa", "Jack", nil];
    }
    return _quotes;

}

- (NSString *) randomQuote {

    return @"Some Quote";
}

@end