From 7ab8a233805a5e71b515798c57459713c5a03835 Mon Sep 17 00:00:00 2001 From: Joel Fischer Date: Wed, 16 Mar 2016 09:57:45 -0400 Subject: Update system version checking with a macro --- SmartDeviceLink-iOS/SmartDeviceLink/SDLGlobals.h | 2 ++ SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m | 2 +- SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink-iOS/SmartDeviceLink/SDLGlobals.h index 03bc9afed..b3778f62e 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink/SDLGlobals.h +++ b/SmartDeviceLink-iOS/SmartDeviceLink/SDLGlobals.h @@ -8,6 +8,8 @@ #import +#define SDL_SYSTEM_VERSION_LESS_THAN(version) ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] == NSOrderedAscending) + @interface SDLGlobals : NSObject @property (assign, nonatomic, readonly) NSUInteger protocolVersion; diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m index 458760e07..00e197a32 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m @@ -363,7 +363,7 @@ const int POLICIES_CORRELATION_ID = 65535; return; } // If system version is less than 9.0 http://stackoverflow.com/a/5337804/1370927 - if ([[[UIDevice currentDevice] systemVersion] compare:@"9.0" options:NSNumericSearch] == NSOrderedAscending) { + if (SDL_SYSTEM_VERSION_LESS_THAN(@"9.0")) { // Return early if we can't openURL because openURL will crash instead of fail silently in < 9.0 if (![[UIApplication sharedApplication] canOpenURL:URLScheme]) { return; diff --git a/SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m index 1ef3a526f..62682c9dc 100644 --- a/SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m @@ -11,6 +11,7 @@ @import UIKit; #import "SDLAbstractProtocol.h" +#import "SDLGlobals.h" NSString *const SDLErrorDomainStreamingMediaVideo = @"com.sdl.streamingmediamanager.video"; @@ -63,8 +64,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Streaming media lifecycle - (void)startVideoSessionWithStartBlock:(SDLStreamingStartBlock)startBlock { - // If system version is less than 8.0 - if ([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending) { + if (SDL_SYSTEM_VERSION_LESS_THAN(@"8.0")) { NSAssert(NO, @"SDL Video Sessions can only be run on iOS 8+ devices"); startBlock(NO, [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLSTreamingVideoErrorInvalidOperatingSystemVersion userInfo:nil]); -- cgit v1.2.1