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!

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

Trouble with animating Crystal Ball App

After watching the tutorial, I typed this code from the video & into Xcode

  self.imageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"cball00001"],[UIImage imageNamed:@"cball00002"],[UIImage imageNamed:@"cball00003"],[UIImage imageNamed:@"cball00004"],[UIImage imageNamed:@"cball00005"],[UIImage imageNamed:@"cball00006"],[UIImage imageNamed:@"cball00007"],[UIImage imageNamed:@"cball00008"],[UIImage imageNamed:@"cball00009"],[UIImage imageNamed:@"cball00010"],[UIImage imageNamed:@"cball00011"],[UIImage imageNamed:@"cball00012"],[UIImage imageNamed:@"cball00013"],[UIImage imageNamed:@"cball00014"],[UIImage imageNamed:@"cball00015"],[UIImage imageNamed:@"cball00016"],[UIImage imageNamed:@"cball00017"],[UIImage imageNamed:@"cball00018"],[UIImage imageNamed:@"cball00019"],[UIImage imageNamed:@"cball00020"],[UIImage imageNamed:@"cball00021"],[UIImage imageNamed:@"cball00022"],[UIImage imageNamed:@"cball00023"],[UIImage imageNamed:@"cball00024"], nil];

For some reason, it's giving me an error message stating that "animationImages" is not found on object type UIImage. How can i fix this? I'm really close to finishing and ont want to give up now

Caleb Abraham
Caleb Abraham
15,158 Points

Hello Fabien. Did you create the imageView @property in the header file and synthesize it before this code? If you didn't create the property, that could explain why the animationImages is not found.

I did insert both lines of code before inserting the animation files. I will probably rewatch the videos before and see what mistake i made. Thank you for your astonishingly quick response! :D

HI Caleb, i thought that replaying the videos would help. I still couldn't find the error within my code. I'm receiving the same error message stating, "Property 'animationDuration' not found on object of type 'UIImage' ,as well as "Property "animationRepeatCount" not found on object of type 'UIImage'.

Please help thanks

Rashii Henry
Rashii Henry
16,433 Points

you probably have to go to the header file of that class and declare a UIImageView property. so whatever UIImage property you have declared change it to UIImageView.

the error was telling you that you can't call animationDuration or animationRepeat count on an UIImage.

sorry this is late, i didn't know it went unanswered.

Rashii Henry
Rashii Henry
16,433 Points

you probably have to go to the header file of that class and declare a UIImageView property. so whatever UIImage property you have declared change it to UIImageView.

the error was telling you that you can't call animationDuration or animationRepeat count on an UIImage.

sorry this is late, i didn't know it went unanswered.

2 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Can you paste the code from ViewController.h file?

yes, if you mean the synthesize & property strings?

Yes, i then was stuck when inserting the animation strings cball00001 through 24 where i still couldnt find the solution

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

Can you paste your code from the header file so I can see how you have defined the @property?

//
//  ViewController.h
//  Crystal Ball DEMO
//
//  Created by fabien bourdon on 6/6/13.
//  Copyright (c) 2013 SPAROS. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController {
    NSArray *predictionArray;
}

@property (strong, nonatomic) IBOutlet UILabel *predictionLabel;
@property (strong, nonatomic)NSArray *predictionArray;
@property (strong, nonatomic)UIImage *imageView;

- (void) makePrediction;

@end
Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

That's your problem. You have defined imageView as an UIImage but it should be a UIImageView.

Thank you very much! This really helped!

Deanna Robertazzi
PLUS
Deanna Robertazzi
Courses Plus Student 2,447 Points

I'm having a similar problem, except it says "animationImages not found on type UILabel". How do I fix my code?