From 85f41927f3e369ffe2594d8ad4e6c0843ac9ef47 Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Thu, 18 Apr 2019 14:22:10 -0700 Subject: [PATCH] Integrate "Annotate SUHost for nullability" --- Sparkle/SUHost.h | 14 +++++++++----- Sparkle/SUHost.m | 16 ++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 1d604984..6e4c2b95 100755 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -7,6 +7,8 @@ #import +NS_ASSUME_NONNULL_BEGIN + @class SUPublicKeys; @interface SUHost : NSObject @@ -24,14 +26,16 @@ @property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume; @property (getter=isRunningTranslocated, readonly) BOOL runningTranslocated; -@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey; +@property (readonly, nonatomic, copy, nullable) NSString *publicDSAKeyFileKey; -- (id)objectForInfoDictionaryKey:(NSString *)key; +- (nullable id)objectForInfoDictionaryKey:(NSString *)key; - (BOOL)boolForInfoDictionaryKey:(NSString *)key; -- (id)objectForUserDefaultsKey:(NSString *)defaultName; -- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName; +- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName; +- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName; - (BOOL)boolForUserDefaultsKey:(NSString *)defaultName; - (void)setBool:(BOOL)value forUserDefaultsKey:(NSString *)defaultName; -- (id)objectForKey:(NSString *)key; +- (nullable id)objectForKey:(NSString *)key; - (BOOL)boolForKey:(NSString *)key; @end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 2b4b7b06..c3da0893 100755 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -15,6 +15,8 @@ #include "AppKitPrevention.h" +NS_ASSUME_NONNULL_BEGIN + // This class should not rely on AppKit and should also be process independent // For example, it should not have code that tests writabilty to somewhere on disk, // as that may depend on the privileges of the process owner. Or code that depends on @@ -25,9 +27,9 @@ @property (strong, readwrite) NSBundle *bundle; @property (nonatomic, readonly) BOOL isMainBundle; -@property (copy) NSString *defaultsDomain; +@property (copy, nullable) NSString *defaultsDomain; @property (assign) BOOL usesStandardUserDefaults; -@property (readonly, copy) NSString *publicDSAKey; +@property (readonly, copy, nullable) NSString *publicDSAKey; @end @@ -176,7 +178,7 @@ return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey]; } -- (id)objectForInfoDictionaryKey:(NSString *)key +- (nullable id)objectForInfoDictionaryKey:(NSString *)key { if (self.isMainBundle) { // Common fast path - if we're updating the main bundle, that means our updater and host bundle's lifetime is the same @@ -200,7 +202,7 @@ return [(NSNumber *)[self objectForInfoDictionaryKey:key] boolValue]; } -- (id)objectForUserDefaultsKey:(NSString *)defaultName +- (nullable id)objectForUserDefaultsKey:(NSString *)defaultName { if (!defaultName || !self.defaultsDomain) { return nil; @@ -218,7 +220,7 @@ } // Note this handles nil being passed for defaultName, in which case the user default will be removed -- (void)setObject:(id)value forUserDefaultsKey:(NSString *)defaultName +- (void)setObject:(nullable id)value forUserDefaultsKey:(NSString *)defaultName { if (self.usesStandardUserDefaults) { @@ -263,7 +265,7 @@ } } -- (id)objectForKey:(NSString *)key { +- (nullable id)objectForKey:(NSString *)key { return [self objectForUserDefaultsKey:key] ? [self objectForUserDefaultsKey:key] : [self objectForInfoDictionaryKey:key]; } @@ -272,3 +274,5 @@ } @end + +NS_ASSUME_NONNULL_END