Commit 3f8b2c0c authored by Victor Gama's avatar Victor Gama Committed by Carola Nitz

Replace availability checks with the modern @available syntax (Fix #116)

This replaces old availability checks performed by checking for class
presence with the new @available syntax. I basically replaced those
checks with @available(VERSION) after checking VERSION on Apple
Developer Documentation
Signed-off-by: default avatarCarola Nitz <nitz.carola@googlemail.com>
(cherry picked from commit a0087846)
parent 08c889aa
...@@ -173,7 +173,7 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize ...@@ -173,7 +173,7 @@ NSString *const VLCDropboxSessionWasAuthorized = @"VLCDropboxSessionWasAuthorize
} }
/* add our static shortcut items the dynamic way to ease l10n and dynamic elements to be introduced later */ /* add our static shortcut items the dynamic way to ease l10n and dynamic elements to be introduced later */
if ([UIApplicationShortcutItem class] != nil) { if (@available(iOS 9, *)) {
if (application.shortcutItems == nil || application.shortcutItems.count < 4) { if (application.shortcutItems == nil || application.shortcutItems.count < 4) {
UIApplicationShortcutItem *localLibraryItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutLocalLibrary UIApplicationShortcutItem *localLibraryItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutLocalLibrary
localizedTitle:NSLocalizedString(@"SECTION_HEADER_LIBRARY",nil) localizedTitle:NSLocalizedString(@"SECTION_HEADER_LIBRARY",nil)
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{ {
return [UIDocumentPickerViewController class] ? 5 : 4;// on iOS 8+ add document picker option return @available(iOS 8.0, *) ? 5 : 4; // on iOS 8+ add document picker option
} }
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
- (void)showDocumentMenuViewController:(id)sender - (void)showDocumentMenuViewController:(id)sender
{ {
if (![UIDocumentMenuViewController class]) if (!@available(iOS 8, *))
return; return;
UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(id)kUTTypeAudiovisualContent] inMode:UIDocumentPickerModeImport]; UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(id)kUTTypeAudiovisualContent] inMode:UIDocumentPickerModeImport];
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
[self setClipsToBounds:YES]; [self setClipsToBounds:YES];
#if TARGET_OS_IOS #if TARGET_OS_IOS
if ([UIVisualEffectView class] != nil) { if (@available(iOS 8, *)) {
_effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]]; _effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
_effectView.frame = self.bounds; _effectView.frame = self.bounds;
_effectView.clipsToBounds = YES; _effectView.clipsToBounds = YES;
......
...@@ -342,7 +342,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -342,7 +342,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
- (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject - (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject
{ {
if ([CSSearchableItemAttributeSet class] != nil && ![VLCKeychainCoordinator passcodeLockEnabled]) { if (@available(iOS 9.0, *) && ![VLCKeychainCoordinator passcodeLockEnabled]) {
self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying]; self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying];
MLFile *file = nil; MLFile *file = nil;
...@@ -1102,7 +1102,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData"; ...@@ -1102,7 +1102,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
NSArray *indexPaths = [self usingTableViewToShowData] ? [self.tableView indexPathsForSelectedRows] : [self.collectionView indexPathsForSelectedItems]; NSArray *indexPaths = [self usingTableViewToShowData] ? [self.tableView indexPathsForSelectedRows] : [self.collectionView indexPathsForSelectedItems];
if ((!indexPaths || [indexPaths count] == 0) && !_deleteFromTableView) { if ((!indexPaths || [indexPaths count] == 0) && !_deleteFromTableView) {
if ([UIAlertController class]) { if (@available(iOS 8, *)) {
UIAlertController *invalidSelection = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DELETE_INVALID_TITLE", nil) message:NSLocalizedString(@"DELETE_INVALID_MESSAGE", nil) preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *invalidSelection = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"DELETE_INVALID_TITLE", nil) message:NSLocalizedString(@"DELETE_INVALID_MESSAGE", nil) preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *doneAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil) style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *doneAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil) style:UIAlertActionStyleDefault handler:nil];
......
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
NSString *renameString = NSLocalizedString(@"BUTTON_RENAME", nil); NSString *renameString = NSLocalizedString(@"BUTTON_RENAME", nil);
NSString *cancelString = NSLocalizedString(@"BUTTON_CANCEL", nil); NSString *cancelString = NSLocalizedString(@"BUTTON_CANCEL", nil);
if ([UIAlertController class]) if (@available(iOS 8, *))
{ {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:renameString UIAlertController *alertController = [UIAlertController alertControllerWithTitle:renameString
message:nil message:nil
......
...@@ -293,7 +293,7 @@ ...@@ -293,7 +293,7 @@
} else } else
#endif #endif
{ {
if ([WKInterfaceDevice class]) { if (@available(iOS 8.2, *)) {
if (WKInterfaceDevice.currentDevice != nil) { if (WKInterfaceDevice.currentDevice != nil) {
CGRect screenRect = WKInterfaceDevice.currentDevice.screenBounds; CGRect screenRect = WKInterfaceDevice.currentDevice.screenBounds;
imageSize = CGSizeMake(screenRect.size.width * WKInterfaceDevice.currentDevice.screenScale, 120.); imageSize = CGSizeMake(screenRect.size.width * WKInterfaceDevice.currentDevice.screenScale, 120.);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
@implementation VLCWatchCommunication @implementation VLCWatchCommunication
+ (BOOL)isSupported { + (BOOL)isSupported {
return [WCSession class] != nil && [WCSession isSupported]; return @available(iOS 9, *) && [WCSession isSupported];
} }
- (instancetype)init - (instancetype)init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment