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 trialDaniel Brooking
5,164 PointsCustom getter for @property vs init
Why couldn't you just set the predictions array within a custom init method? When you alloc init the CrystalBall class, your predictions array would get generated and populated with the strings, and then the normal getter/setter would work as expected, no?
2 Answers
Stone Preston
42,016 Pointsyou could do it that way. I think they did it that way just to show how to use custom getters/setters.
Daniel Brooking
5,164 PointsThanks. I've dabbled in iOS dev for a while and this is my first time taking any actual training course. I've always done it via the init but was now wondering if I was doing it wrong. Good to hear it could be either.