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

General Discussion

Instruct your 'imageView' to start running the animation.

On the .h file I have

import "UIViewController.h"

@interface THViewController : UIViewController

@property (nonatomic, strong) UIImageView *imageView;

[self.imageView startAnimating];

@end

and the .m file I have

import "THViewController.h"

@implementation THViewController

  • (void)viewDidLoad { [super viewDidLoad];

    // backgroundImage is a local variable UIImage *backgroundImage = [UIImage imageNamed:@"background"]; // imageView is a property self.imageView = [[UIImageView alloc] initWithImage:backgroundImage];

    // Add your code below! // Remember 'imageView' is a property // so refer to it as 'self.imageView' self.imageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"01.png"], [UIImage imageNamed:@"02.png"], [UIImage imageNamed:@"03.png"], nil];

self.imageView.animationDuration = 5.0f; }

  • (void)startAnimating { }

@end

Why is it giving me an error to call the appropriate image view?

7 Answers

[self.imageView startAnimating]; is a method call. Method calls are done in the implementation file (the .m file) not the header file (the .h file).

opps, I forgot about that. So that means that I dont add anything to the .h file right?

I am still getting an error though. What is wrong?

I would suggest going back and rewatching the video on iOS animations, I think it would clear a few things up for you.

Your code still isn't working because you attempted to write your own method called startAnimating instead of calling the built-in startAnimating method on the UIImageView property.

I rewatched the video and am still confused. Can you show me the answer? I will try to find what I did wrong from there

I'm don't want to post the exact code because debugging is a big part of learning to program.

To pass this code challenge you will need to remove (void)startAnimating { } since that is not needed at all (startAnimating is provided by Apple) and then in viewDidLoad you will want to call startAnimating on the UIImageView.

Again it is all in the video if you get stuck.

okay. thanks!