From b7f9a052ac9bf4b0450e87396c5f1a96af2d9d32 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 18 Nov 2016 08:20:06 -0600 Subject: [PATCH] Removing UIKit to prepare the way to support OS X with this library. OSx target not created yet but code should be good to go. --- .../DSAPINetworkIndicatorController.h | 3 +++ .../DSAPINetworkIndicatorController.m | 15 ++++++++++++++- .../DeskAPIClientTests/DSAPIBrandTests.m | 2 +- .../DeskAPIClientTests/DSAPIListProviderTests.m | 2 +- .../DeskAPIClientTests/DSAPIPermissionTests.m | 2 +- DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m | 2 +- .../DeskAPIClientTests-Prefix.pch | 1 - 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.h b/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.h index 1559d51..c9890e7 100644 --- a/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.h +++ b/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.h @@ -28,7 +28,10 @@ // POSSIBILITY OF SUCH DAMAGE. // +#import +#if TARGET_OS_IPHONE #import +#endif @interface DSAPINetworkIndicatorController : NSObject diff --git a/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.m b/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.m index 431c5db..1523d3a 100644 --- a/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.m +++ b/DeskAPIClient/DeskAPIClient/DSAPINetworkIndicatorController.m @@ -64,24 +64,28 @@ - (instancetype)init - (void)networkActivityDidStart { +#if TARGET_OS_IPHONE NSAssert([NSThread isMainThread], @"Altering network activity indicator state can only be done on the main thread."); self.activityCount++; [self updateIndicatorVisibility]; +#endif } - (void)networkActivityDidEnd { +#if TARGET_OS_IPHONE NSAssert([NSThread isMainThread], @"Altering network activity indicator state can only be done on the main thread."); NSAssert(self.activityCount > 0, @"networkActivityDidEnd before matching networkActivityDidStart"); self.activityCount--; [self updateIndicatorVisibility]; - + #endif } #pragma mark - Private - (void)updateIndicatorVisibility { +#if TARGET_OS_IPHONE if (self.activityCount > 0) { [self showIndicator]; } else { @@ -92,31 +96,40 @@ - (void)updateIndicatorVisibility */ [self createTimerToHideIndicator]; } +#endif } - (void)createTimerToHideIndicator { +#if TARGET_OS_IPHONE self.timer = [NSTimer scheduledTimerWithTimeInterval:0.75 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO]; self.timer.tolerance = 0.5; +#endif } - (void)timerFireMethod:(NSTimer *)timer { +#if TARGET_OS_IPHONE [self hideIndicator]; +#endif } - (void)showIndicator { +#if TARGET_OS_IPHONE [self.timer invalidate]; self.timer = nil; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; +#endif } - (void)hideIndicator { +#if TARGET_OS_IPHONE [self.timer invalidate]; self.timer = nil; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; +#endif } diff --git a/DeskAPIClient/DeskAPIClientTests/DSAPIBrandTests.m b/DeskAPIClient/DeskAPIClientTests/DSAPIBrandTests.m index 1162dd4..94e1c63 100644 --- a/DeskAPIClient/DeskAPIClientTests/DSAPIBrandTests.m +++ b/DeskAPIClient/DeskAPIClientTests/DSAPIBrandTests.m @@ -28,7 +28,7 @@ // POSSIBILITY OF SUCH DAMAGE. // -#import +#import #import "DSAPITestCase.h" @interface DSAPIBrandTests : DSAPITestCase diff --git a/DeskAPIClient/DeskAPIClientTests/DSAPIListProviderTests.m b/DeskAPIClient/DeskAPIClientTests/DSAPIListProviderTests.m index 8fe832f..27371c5 100644 --- a/DeskAPIClient/DeskAPIClientTests/DSAPIListProviderTests.m +++ b/DeskAPIClient/DeskAPIClientTests/DSAPIListProviderTests.m @@ -28,7 +28,7 @@ // POSSIBILITY OF SUCH DAMAGE. // -#import +#import #import #import "DSAPIResource+Testing.h" #import "DSAPIListProvider.h" diff --git a/DeskAPIClient/DeskAPIClientTests/DSAPIPermissionTests.m b/DeskAPIClient/DeskAPIClientTests/DSAPIPermissionTests.m index 109284d..836bbf8 100644 --- a/DeskAPIClient/DeskAPIClientTests/DSAPIPermissionTests.m +++ b/DeskAPIClient/DeskAPIClientTests/DSAPIPermissionTests.m @@ -6,7 +6,7 @@ // Copyright (c) 2015 Desk.com. All rights reserved. // -#import +#import #import "DSAPITestCase.h" #import "DSAPIETagCache.h" diff --git a/DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m b/DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m index 8c09332..c3a95af 100644 --- a/DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m +++ b/DeskAPIClient/DeskAPIClientTests/DSAPISiteTests.m @@ -28,7 +28,7 @@ // POSSIBILITY OF SUCH DAMAGE. // -#import +#import #import "DSAPITestCase.h" @interface DSAPISiteTests : DSAPITestCase diff --git a/DeskAPIClient/DeskAPIClientTests/DeskAPIClientTests-Prefix.pch b/DeskAPIClient/DeskAPIClientTests/DeskAPIClientTests-Prefix.pch index 20c8754..1d6bcd3 100644 --- a/DeskAPIClient/DeskAPIClientTests/DeskAPIClientTests-Prefix.pch +++ b/DeskAPIClient/DeskAPIClientTests/DeskAPIClientTests-Prefix.pch @@ -5,7 +5,6 @@ // #ifdef __OBJC__ - #import #import #define EXP_SHORTHAND YES #import "Expecta.h"