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 trialkirkbyo
15,791 PointsWhat am I doing wrong here
I don't what I am doing wrong here.
Q: Within the implementation file we need to modify the 'randomQuote' method to return a random quote from the 'quotes' array using the arc4random_uniform() function.
Error: Bummer! Remember to use the 'arc4random_uniform()' function to return a random quote from the 'quotes' array property.
@implementation Quote
- (NSString *) randomQuote {
int randomQuote = arc4random_uniform(self.quotes.count);
return [self.quotes objectAtIndex:randomQuote];
}
- (NSArray *) quotes{
if (_quotes == nil){
_quotes = [[NSArray alloc] initWithObjects:@"It is certain", @"It is decidely so", @"Maybe", nil];
}
return _quotes;
}
@end
2 Answers
Amit Bijlani
Treehouse Guest TeacherYour answer is right and it worked for me. Maybe you want to give a try once again.
kirkbyo
15,791 PointsThat is weird, it worked for me now. Thanks for your help :)