Created
May 3, 2011 16:26
-
-
Save mwaterfall/953659 to your computer and use it in GitHub Desktop.
Suppressing depreciation warnings that have been addressed
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
// Depreciation Suppression | |
@protocol SuppressDepreciationWarning | |
- (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated; // UIApplication - Deprecated in iPhone OS 3.2 | |
@end | |
// Hide status bar | |
if ([UIApplication instancesRespondToSelector:@selector(setStatusBarHidden:withAnimation:)]) { | |
[SharedApplication setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; | |
} else { | |
[(id <SuppressDepreciationWarning>)SharedApplication setStatusBarHidden:YES animated:YES]; // Depreciated | |
} | |
/* | |
* Handy preprocessor macro for status bar animation | |
*/ | |
// Animate status bar - with animation style if possible (iOS 3.2+) | |
#define SetStatusBarHiddenWithAnimation(hide, ani) if ([UIApplication instancesRespondToSelector:@selector(setStatusBarHidden:withAnimation:)]) [SharedApplication setStatusBarHidden:hide withAnimation:ani]; else [(id <SuppressDepreciationWarning>)SharedApplication setStatusBarHidden:hide animated:YES]; | |
// Usage | |
SetStatusBarHiddenWithAnimation(NO, UIStatusBarAnimationSlide); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With new iOS releases, API methods are depreciated and newer (better) methods introduced.
If you want to use these better methods and still support older iOS versions, you'll be stuck with many Xcode depreciation warnings. All build warnings are very useful, however once you have addressed an issue that warning will stick around and clutter up your build results.
Here's a great technique for manually suppressing these warnings when you have handled that particular depreciation.
Source vgable.com/blog/2009/06/15/ignoring-just-one-deprecated-warning/