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) Understanding Views and View Controllers CGRect and Frame

super viewdidappear, I think that's redundant

At 8.57 we add [super viewDidAppear:animated]; in the viewDidAppear implementation, but why we add it? I noticed that if we remove it out, the result won't change, I think that's a redundant statement...

2 Answers

Holger Liesegang
Holger Liesegang
50,595 Points

Hi Francesco,

when you are overriding a method (and that's exactly what's happening here), you want to keep what the method of the superclass is doing and just add something new on top of it (in your subclass). That's what you're doing when calling super: the superclass is doing what it's supposed to do first. So when overriding a method without using super it might go well for a time but it most likely will crash your App at some point in the future.

Also to be 100% sure you can consult the Apple documentation for viewDidAppear: which states : "If you override this method, you must call super at some point in your implementation."

Kind Regards Holger

Thanks! Very clear explanation!