From 282f0ae58e15fcdbd9f46bc9704c77912410614a Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 16 Jan 2017 18:09:04 -0500 Subject: [PATCH] Add Obj-C generics where applicable In headers that are exported, we test to see if generic support is available. --- Sparkle/SUAppcast.h | 5 +++++ Sparkle/SUAppcast.m | 2 +- Sparkle/SUSystemProfiler.h | 2 +- Sparkle/SUSystemProfiler.m | 8 ++++---- Sparkle/SUUpdater.h | 4 ++++ Sparkle/SUUpdater.m | 2 +- Sparkle/SUUpdaterDelegate.h | 4 ++++ 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUAppcast.h b/Sparkle/SUAppcast.h index c81994b4..55fc4bc7 100644 --- a/Sparkle/SUAppcast.h +++ b/Sparkle/SUAppcast.h @@ -22,7 +22,12 @@ NS_ASSUME_NONNULL_BEGIN SU_EXPORT @interface SUAppcast : NSObject @property (copy, nullable) NSString *userAgentString; + +#if __has_feature(objc_generics) +@property (copy, nullable) NSDictionary *httpHeaders; +#else @property (copy, nullable) NSDictionary *httpHeaders; +#endif - (void)fetchAppcastFromURL:(NSURL *)url completionBlock:(void (^)(NSError *_Nullable))err; - (SUAppcast *)copyWithoutDeltaUpdates; diff --git a/Sparkle/SUAppcast.m b/Sparkle/SUAppcast.m index 8873854a..70b56f0a 100644 --- a/Sparkle/SUAppcast.m +++ b/Sparkle/SUAppcast.m @@ -65,7 +65,7 @@ if (self.httpHeaders) { for (NSString *key in self.httpHeaders) { - id value = [self.httpHeaders objectForKey:key]; + NSString *value = [self.httpHeaders objectForKey:key]; [request setValue:value forHTTPHeaderField:key]; } } diff --git a/Sparkle/SUSystemProfiler.h b/Sparkle/SUSystemProfiler.h index 6223e22e..4bf05472 100644 --- a/Sparkle/SUSystemProfiler.h +++ b/Sparkle/SUSystemProfiler.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @class SUHost; @interface SUSystemProfiler : NSObject -+ (NSArray *)systemProfileArrayForHost:(SUHost *)host; ++ (NSArray *> *)systemProfileArrayForHost:(SUHost *)host; @end diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index ae2f10f5..83a93cee 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -28,19 +28,19 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang"; @implementation SUSystemProfiler -+ (NSDictionary *)modelTranslationTable ++ (NSDictionary *)modelTranslationTable { // Use explicit class to use the correct bundle even when subclassed NSString *path = [[NSBundle bundleForClass:[SUSystemProfiler class]] pathForResource:@"SUModelTranslation" ofType:@"plist"]; return [[NSDictionary alloc] initWithContentsOfFile:path]; } -+ (NSArray *)systemProfileArrayForHost:(SUHost *)host ++ (NSArray *> *)systemProfileArrayForHost:(SUHost *)host { - NSDictionary *modelTranslation = [self modelTranslationTable]; + NSDictionary *modelTranslation = [self modelTranslationTable]; // Gather profile information and append it to the URL. - NSMutableArray *profileArray = [NSMutableArray array]; + NSMutableArray *> *profileArray = [NSMutableArray array]; NSArray *profileDictKeys = @[@"key", @"displayKey", @"value", @"displayValue"]; int error = 0; int value = 0; diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index f627ed14..679f1b79 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -160,7 +160,11 @@ SU_EXPORT @interface SUUpdater : NSObject The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString) */ +#if __has_feature(objc_generics) +@property (copy) NSDictionary *httpHeaders; +#else @property (copy) NSDictionary *httpHeaders; +#endif /*! A property indicating whether or not the user's system profile information is sent when checking for updates. diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 7794db19..e9ff87e4 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -210,7 +210,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults } if (shouldPrompt) { - NSArray *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host]; + NSArray *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host]; // Always say we're sending the system profile here so that the delegate displays the parameters it would send. if ([self.delegate respondsToSelector:@selector(feedParametersForUpdater:sendingSystemProfile:)]) { profileInfo = [profileInfo arrayByAddingObjectsFromArray:[self.delegate feedParametersForUpdater:self sendingSystemProfile:YES]]; diff --git a/Sparkle/SUUpdaterDelegate.h b/Sparkle/SUUpdaterDelegate.h index 522764ed..39249ac4 100644 --- a/Sparkle/SUUpdaterDelegate.h +++ b/Sparkle/SUUpdaterDelegate.h @@ -64,7 +64,11 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; \return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user. */ +#if __has_feature(objc_generics) +- (NSArray *> *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile; +#else - (NSArray *)feedParametersForUpdater:(SUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile; +#endif /*! Returns a custom appcast URL.