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 Build a Simple iPhone App (iOS7) Animating and Intercepting Events Intercepting Motion Events

Dawid Cedrych
Dawid Cedrych
15,108 Points

little error

When I make motionBegan and other motion methods, my project behaves like these methods were not declared before, do you have any idea why? I downloaded Amit's project and there's no additional lines of codes in .h, nevertheless .m file recognizes motion methods…Do I miss something?

6 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

What do you mean by "my project behaves like these methods were not declared before"? Do you get any errors?

BTW you don't have to declare

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

in the THViewController.h because THViewController inherits from UIViewController and UIViewController from the UIResponder Class where the above given instance methods are already declared.

You might want to have a look at UIResponder Class Reference

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Dawid,

would you mind elaborating on this matter, please?

Dawid Cedrych
Dawid Cedrych
15,108 Points

Sorry, I've already edited my post

Dawid Cedrych
Dawid Cedrych
15,108 Points

Yes, but on the video when Amit typed "motion" he has got auto-prompt motionBegan, but when I start typing "motion" I do not have any auto-prompt, which means that implementation file cannot find it in header.

Holger Liesegang
Holger Liesegang
50,595 Points

Try typing -motion (with the - and no space between "-" and "motion") that will start the auto completion.

Dawid Cedrych
Dawid Cedrych
15,108 Points

Alright, my stupid mistake, I overlooked one braces and tried to type it inside other method, what a silly mistake!! Sorry everybody!