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

App fails to compile after adding readonly attribute (Build a Simple iPhone App (iOS7) > Refactoring into a Model > Readonly Attribute)

If you try to run the app after finishing this video, it fails to compile. In the THCrystallBall.m file I get an error whenever using _predictions that says Use of undeclared identifier '_predictions'

Upon deleting the readonly attribute from the predictions property, the errors go away and the app once again works. Did I miss something?

2 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Since the property is declared as readonly an instance variable is not being created for you. So one needs to be manually created.

Modify the the header of THCrystalBall.h to:

@interface THCrystalBall : NSObject {
    NSArray *_predictions;
}

Sorry about it, I will be modifying the video next week to address this issue.

Thanks for your quick reply! Your videos are very helpful, thanks so much for doing this series :)