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


Alex Atwater
Alex Atwater
2,624 Points

ARC memory release issue


  • (void)viewDidLoad {

    [super viewDidLoad];

    self.predictionsObjectArray = [[AAPredictions alloc] init];

    [self.predictionsObjectArray setPredictionsArray:@[@"Probably Not", @"Ask Again", @"I doubt it", @"Unlikely", @"I believe so"]];

    for (int x = 1; x<61; x++) { NSMutableString *imageName = [[NSMutableString alloc] init]; if (x > 9) { imageName = [NSMutableString stringWithFormat:@"CB000%i.png", x]; } else { imageName = [NSMutableString stringWithFormat:@"CB0000%i.png", x]; }

    [self.animationImagesArray addObject:[UIImage imageNamed:imageName]];




‘'' -(void)makePrediction { self.predictionLabel.text = [self.predictionsObjectArray getPrediction]; [self animateItems]; ‘’’

‘'' } -(void)animateItems {

self.image_button.alpha = 0.0;

self.background_image.animationRepeatCount = 1.0;

self.background_image.animationImages = self.animationImagesArray;

self.background_image.animationDuration = 3.0;
[self.background_image startAnimating];

while (self.background_image.isAnimating) {


self.image_button.alpha = 1.0;

} ‘''

making a simple crystal Ball app, and am trying to animate it… I have really been working at this for a while with no luck… Hoping someone can help me as i am learning… particularly the ARC. I know i need to add a line in the viewDidLoad function to add the reference count to +1 of self.animationImagesArray, because when i goto assign self.background_image.animationImages to self.animationImagesArray, ARC released it and i know because in the debugger ar the bottom, it’s value in nil. Any help would be great.

1 Answer

Did you remember to initialize your self.animationImagesArray as an empty array before you start adding things in?