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

Refactoring Code Challenge

I'm having a hard time with the 3rd part of the code challenge for the Crystal Ball - Refactoring into a Model. I've looked through the forums and haven't found anything that really helped.

Here is my code for the third section:

#import "Quote.h"

@implementation Quote

- (NSArray *) quotes {
            if (_quotes == nil){
            _quotes = [[NSArray alloc] initWithObjects:@"0", @"1", @"2", nil];
      }
        return _quotes;
}

- (NSString *) randomQuote {
        init random = arc4random_uniform(self.quotes.count);
    return [self.quotes objectAtIndex:random];
    }
@end

1 Answer

Without knowing the question, it's usually very hard for others to know what's wrong.

Except there is a bug in your code. You have init random ... while I believe you meant int random ...

Thanks! I must have missed that... What is "int"?

int stands for integer