Sfoglia il codice sorgente

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: Carola Nitz <nitz.carola@googlemail.com>
Victor Gama 7 anni fa
parent
commit
a00878464c

+ 1 - 1
Sources/VLCAppDelegate.m

@@ -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 */
-    if ([UIApplicationShortcutItem class] != nil) {
+    if (@available(iOS 9, *)) {
         if (application.shortcutItems == nil || application.shortcutItems.count < 4) {
             UIApplicationShortcutItem *localLibraryItem = [[UIApplicationShortcutItem alloc] initWithType:kVLCApplicationShortcutLocalLibrary
                                                                                            localizedTitle:NSLocalizedString(@"SECTION_HEADER_LIBRARY",nil)

+ 1 - 1
Sources/VLCCloudServicesTableViewController.m

@@ -75,7 +75,7 @@
 
 - (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

+ 1 - 1
Sources/VLCDocumentPickerController.m

@@ -25,7 +25,7 @@
 
 - (void)showDocumentMenuViewController:(id)sender
 {
-    if (![UIDocumentMenuViewController class])
+    if (!@available(iOS 8, *))
         return;
 
     UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(id)kUTTypeAudiovisualContent] inMode:UIDocumentPickerModeImport];

+ 1 - 1
Sources/VLCFrostedGlasView.m

@@ -52,7 +52,7 @@
     [self setClipsToBounds:YES];
 
 #if TARGET_OS_IOS
-    if ([UIVisualEffectView class] != nil) {
+    if (@available(iOS 8, *)) {
         _effectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
         _effectView.frame = self.bounds;
         _effectView.clipsToBounds = YES;

+ 2 - 2
Sources/VLCLibraryViewController.m

@@ -342,7 +342,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
 
 - (void)createSpotlightItem:(nonnull NSManagedObject *)mediaObject
 {
-    if ([CSSearchableItemAttributeSet class] != nil && ![VLCKeychainCoordinator passcodeLockEnabled]) {
+    if (@available(iOS 9.0, *) && ![VLCKeychainCoordinator passcodeLockEnabled]) {
         self.userActivity = [[NSUserActivity alloc] initWithActivityType:kVLCUserActivityPlaying];
 
         MLFile *file = nil;
@@ -1102,7 +1102,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
     NSArray *indexPaths = [self usingTableViewToShowData] ? [self.tableView indexPathsForSelectedRows] : [self.collectionView indexPathsForSelectedItems];
 
     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];
             UIAlertAction *doneAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_OK", nil) style:UIAlertActionStyleDefault handler:nil];
 

+ 1 - 1
Sources/VLCOpenNetworkStreamViewController.m

@@ -201,7 +201,7 @@
     NSString *renameString = NSLocalizedString(@"BUTTON_RENAME", nil);
     NSString *cancelString = NSLocalizedString(@"BUTTON_CANCEL", nil);
 
-    if ([UIAlertController class])
+    if (@available(iOS 8, *))
     {
         UIAlertController *alertController = [UIAlertController alertControllerWithTitle:renameString
                                                                                  message:nil

+ 1 - 1
Sources/VLCThumbnailsCache.m

@@ -293,7 +293,7 @@
     } else
 #endif
     {
-        if ([WKInterfaceDevice class]) {
+        if (@available(iOS 8.2, *)) {
             if (WKInterfaceDevice.currentDevice != nil) {
                 CGRect screenRect = WKInterfaceDevice.currentDevice.screenBounds;
                 imageSize = CGSizeMake(screenRect.size.width * WKInterfaceDevice.currentDevice.screenScale, 120.);

+ 1 - 1
Sources/VLCWatchCommunication.m

@@ -27,7 +27,7 @@
 @implementation VLCWatchCommunication
 
 + (BOOL)isSupported {
-    return [WCSession class] != nil && [WCSession isSupported];
+    return @available(iOS 9, *) && [WCSession isSupported];
 }
 
 - (instancetype)init