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 trialDemetrios Tsakiris
Courses Plus Student 1,935 PointsCustom Class not working as shown in video on my end
after creating the custom class THCrystalBall. when doing the following line: self.crystalBall = [[THCrystalBall alloc] init]; the array is not being initialized. I have re-watched the vids and i have done everything as he has written the code. So basically the "getter" function is not executing. I added a line below the alloc init NSLog(@"predictions %@",self.crystalBall.predictions); this fires the getting which puts all the values into the array. I know because via debugger it finally went into that code where i had a breakpoint set. either i missed one step or something is wrong with the vid. please advise.
1 Answer
Demetrios Tsakiris
Courses Plus Student 1,935 Pointsnever mind. i found the problem
before:
// method returning random string from instance array for the class
- (NSString*) randomPrediciton{
int random = arc4random_uniform(_predictions.count); <-- problem here instead of self. i had _predictions
// return value from array with random index
return [_predictions objectAtIndex:random];
}
after:
// method returning random string from instance array for the class
- (NSString*) randomPrediciton{
int random = arc4random_uniform(self.predictions.count);
// return value from array with random index
return [_predictions objectAtIndex:random];
}
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post your getter for the property?