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

Jose Macias
1,545 PointsCreating a Custom Class- Code Challenge
Tried, but can seem to understand the problem need help!!!!
13 Answers

Josef Coban
7,260 PointsCan you please be more specific with you problem? copy/paste the question in here and perhaps the code you tried to use as well.

agreatdaytocode
24,757 Points
Jose Macias
1,545 Pointsbut i need task 1

Jose Macias
1,545 PointsHi can you still help me on task 1 and 3

agreatdaytocode
24,757 PointsSure send me a link to the challenge :)

agreatdaytocode
24,757 PointsI mean post the link here lol.

Jose Macias
1,545 PointsWell i just found out what task 1 was!!!

Jose Macias
1,545 PointsHere's the link i need help on task 3..

agreatdaytocode
24,757 Points:) awesome it was part of 2 right?

Jose Macias
1,545 PointsHelp!

agreatdaytocode
24,757 PointsI know I posting all parts for others that come and search for answers :)

Jose Macias
1,545 Pointsok

agreatdaytocode
24,757 PointsPart one.
@interface Quote : NSObject
// Add property here
@property (strong, nonatomic) NSArray *quotes;
- (NSString *) randomQuote;
@end

Jose Macias
1,545 PointsI already got that need help on part 3

agreatdaytocode
24,757 PointsPart 2
@implementation Quote
- (NSArray *) quotes {
if (_quotes == nil){
_quotes = [[NSArray alloc] initWithObjects:@"One", @"two", @"three", nil];
}
return _quotes;
}
- (NSString *) randomQuote {
return @"Some Quote";
}
@end

agreatdaytocode
24,757 PointsPart Three
- (NSString *) randomQuote {
int random = arc4random_uniform(self.quotes.count); //Add this line
return [self.quotes objectAtIndex:random]; //Add this line too its in the last mins of the video
}
@end

Jose Macias
1,545 PointsStill not working can u just copy and paste the entire page of code!

agreatdaytocode
24,757 PointsJose I don't have a Crystal ball that allows me to read your code. Please post it if you want help.

Jose Macias
1,545 PointsI meant can you copy your code Not mine!

agreatdaytocode
24,757 Points@implementation Quote
- (NSArray *) quotes {
if (_quotes == nil){
_quotes = [[NSArray alloc] initWithObjects:@"One", @"two", @"three", nil];
}
return _quotes;
}
- (NSString *) randomQuote {
int random = arc4random_uniform(self.quotes.count); //Add this line
return [self.quotes objectAtIndex:random]; //Add this line too its in the last mins of the video
}
@end
This is part three from top to bottom. If you can't get this to work, I suggest watching the video again.

Jose Macias
1,545 PointsStill not working ok ill watch it

agreatdaytocode
24,757 PointsIf its not working you are missing something post your code.

Jose Macias
1,545 Pointsimport "Quote.h"
@implementation Quote
(NSArray *) quotes { if (_quotes == nil){ _quotes = [[NSArray alloc] initWithObjects:@"One", @"two", @"three", nil]; } return _quotes; }
(NSString *) randomQuote { int random = arc4random_uniform(self.quotes.count); //Add this line return [self.quotes objectAtIndex:random]; //Add this line too its in the last mins of the video }
@end

agreatdaytocode
24,757 PointsLOL add the follow to the very top.
import "Quote.h"

Jose Macias
1,545 Pointsits already there

agreatdaytocode
24,757 Pointsyour code does not have dashes next to NSArray or the NSString look at the code I posted.

Jose Macias
1,545 Pointstried it still not working

agreatdaytocode
24,757 Pointsare you posting it under the .h file or .m file?

Jose Macias
1,545 Points.h file

Jose Macias
1,545 PointsI meant .m file

agreatdaytocode
24,757 PointsOK, look here young grasshopper, the first part is for the .h 2 and 3 go under .m

agreatdaytocode
24,757 PointsI don't know whats wrong. Try typing it in, maybe copy and paste is throwing it off?

Jose Macias
1,545 Pointswell idk either Thanks anyway!

agreatdaytocode
24,757 Pointsyou can also try taking out my comments //add... //add..

Jose Macias
1,545 Pointsi did

agreatdaytocode
24,757 PointsIll post images maybe that will help you?
