From bdd2b7571bb56ec889f0cdc94cd6aee59f80fa9d Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 6 Aug 2016 20:47:30 -0400 Subject: [PATCH] Mark SPUUpdater with nullability annotations --- Sparkle/SPUUpdater.h | 12 ++++++++---- Sparkle/SPUUpdater.m | 11 ++++++++++- Sparkle/SUAppcastDriver.h | 2 +- Sparkle/SUAppcastDriver.m | 2 +- Sparkle/SUBasicUpdateDriver.h | 2 +- Sparkle/SUBasicUpdateDriver.m | 2 +- Sparkle/SUProbingUpdateDriver.m | 2 +- Sparkle/SUUpdateDriver.h | 2 +- 8 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Sparkle/SPUUpdater.h b/Sparkle/SPUUpdater.h index 85081c75..8e704afe 100644 --- a/Sparkle/SPUUpdater.h +++ b/Sparkle/SPUUpdater.h @@ -14,6 +14,8 @@ #import "SUExport.h" #import "SPUUserDriver.h" +NS_ASSUME_NONNULL_BEGIN + @class SUAppcastItem, SUAppcast; @protocol SUUpdaterDelegate; @@ -43,7 +45,7 @@ SU_EXPORT @interface SPUUpdater : NSObject * * This must be called on the main thread. */ -- (instancetype)initWithHostBundle:(NSBundle *)hostBundle userDriver:(id )userDriver delegate:(id )delegate; +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; /*! * Starts the updater. @@ -58,7 +60,7 @@ SU_EXPORT @interface SPUUpdater : NSObject */ - (BOOL)startUpdater:(NSError * __autoreleasing *)error; -@property (weak, readonly) id delegate; +@property (weak, readonly, nullable) id delegate; @property (nonatomic, readonly) id userDriver; @property (readonly, strong) NSBundle *hostBundle; @@ -77,7 +79,7 @@ SU_EXPORT @interface SPUUpdater : NSObject @property (nonatomic, copy) NSString *userAgentString; -@property (copy) NSDictionary *httpHeaders; +@property (copy, nullable) NSDictionary *httpHeaders; @property (nonatomic) BOOL sendsSystemProfile; @@ -108,7 +110,7 @@ SU_EXPORT @interface SPUUpdater : NSObject \returns \c nil if no check has been performed. */ -@property (readonly, copy) NSDate *lastUpdateCheckDate; +@property (readonly, copy, nullable) NSDate *lastUpdateCheckDate; /*! Begins a "probing" check for updates which will not actually offer to @@ -131,3 +133,5 @@ SU_EXPORT @interface SPUUpdater : NSObject - (void)resetUpdateCycle; @end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 54f5bade..900f0853 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -658,7 +658,16 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"]; NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; - return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding]; + + NSString *result = @""; + if (cleanedAgent != nil) { + NSString *cleanedAgentString = [[NSString alloc] initWithData:(NSData * _Nonnull)cleanedAgent encoding:NSASCIIStringEncoding]; + if (cleanedAgentString != nil) { + result = cleanedAgentString; + } + } + + return result; } - (void)setSendsSystemProfile:(BOOL)sendsSystemProfile diff --git a/Sparkle/SUAppcastDriver.h b/Sparkle/SUAppcastDriver.h index 3448e330..1c2adc0c 100644 --- a/Sparkle/SUAppcastDriver.h +++ b/Sparkle/SUAppcastDriver.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(nullable id )delegate; -- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates; +- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates; @property (nullable, nonatomic, readonly) SUAppcastItem *nonDeltaUpdateItem; diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index af054d61..9c011d84 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -52,7 +52,7 @@ return self; } -- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates +- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates { self.userAgent = userAgent; diff --git a/Sparkle/SUBasicUpdateDriver.h b/Sparkle/SUBasicUpdateDriver.h index b17db957..6c409137 100644 --- a/Sparkle/SUBasicUpdateDriver.h +++ b/Sparkle/SUBasicUpdateDriver.h @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id )delegate; -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(SUUpdateDriverCompletion)completionBlock; +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(SUUpdateDriverCompletion)completionBlock; - (void)resumeInstallingUpdateWithCompletion:(SUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 8aa4bc3d..09044e60 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -56,7 +56,7 @@ return self; } -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(SUUpdateDriverCompletion)completionBlock +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(SUUpdateDriverCompletion)completionBlock { self.completionBlock = completionBlock; diff --git a/Sparkle/SUProbingUpdateDriver.m b/Sparkle/SUProbingUpdateDriver.m index f1c891ea..0f5df49a 100644 --- a/Sparkle/SUProbingUpdateDriver.m +++ b/Sparkle/SUProbingUpdateDriver.m @@ -34,7 +34,7 @@ return self; } -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(SUUpdateDriverCompletion)completionBlock +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders completion:(SUUpdateDriverCompletion)completionBlock { [self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders includesSkippedUpdates:NO completion:completionBlock]; } diff --git a/Sparkle/SUUpdateDriver.h b/Sparkle/SUUpdateDriver.h index aadce8b9..6d6d69f5 100644 --- a/Sparkle/SUUpdateDriver.h +++ b/Sparkle/SUUpdateDriver.h @@ -14,7 +14,7 @@ typedef void (^SUUpdateDriverCompletion)(BOOL shouldShowUpdateImmediately, SUDow @protocol SUUpdateDriver -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders completion:(SUUpdateDriverCompletion)completionBlock; +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders completion:(SUUpdateDriverCompletion)completionBlock; - (void)resumeInstallingUpdateWithCompletion:(SUUpdateDriverCompletion)completionBlock;