This method will help to prevent a lot of emails about "weird bugs".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defines a yet undocumented method to add a warning if super isn't called. | |
#ifndef NS_REQUIRES_SUPER | |
#if __has_attribute(objc_requires_super) | |
#define NS_REQUIRES_SUPER __attribute((objc_requires_super)) | |
#else | |
#define NS_REQUIRES_SUPER | |
#endif | |
#endif | |
@interface UIViewController (SubclassingWarnings) | |
// PSPDFKit overrides all kind of event hooks for UIViewController. | |
// You should always call super on those, even if you're just using UIViewController. | |
- (void)viewWillAppear:(BOOL)animated NS_REQUIRES_SUPER; | |
- (void)viewDidAppear:(BOOL)animated NS_REQUIRES_SUPER; | |
- (void)viewWillDisappear:(BOOL)animated NS_REQUIRES_SUPER; | |
- (void)viewDidDisappear:(BOOL)animated NS_REQUIRES_SUPER; | |
- (void)viewWillLayoutSubviews NS_REQUIRES_SUPER; | |
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_REQUIRES_SUPER; | |
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_REQUIRES_SUPER; | |
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation NS_REQUIRES_SUPER; | |
- (void)didReceiveMemoryWarning NS_REQUIRES_SUPER; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not work for me (Xcode 5.0.2, Build 5A3005). However, it works if I redeclare the
UIViewController
methods withNS_REQUIRES_SUPER
in a category onPSPDFViewController
(instead of in a category onUIViewController
).@steipete Any comments, hints, or ideas about that behavior and why it does not work with the Gist above?