From 7bb0c69f76ee43576b98d708b7b153b3e497f0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 28 Jun 2015 22:21:37 +0100 Subject: [PATCH] Nullability --- Sparkle/SUAppcastItem.m | 5 +++-- Sparkle/SUAutomaticUpdateAlert.m | 6 +++--- Sparkle/SUHost.m | 8 ++++---- Sparkle/Sparkle.pch | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Sparkle/SUAppcastItem.m b/Sparkle/SUAppcastItem.m index cde1ccd0..2a11f247 100644 --- a/Sparkle/SUAppcastItem.m +++ b/Sparkle/SUAppcastItem.m @@ -152,8 +152,9 @@ } // Find the appropriate release notes URL. - if (dict[SUAppcastElementReleaseNotesLink]) { - self.releaseNotesURL = [NSURL URLWithString:dict[SUAppcastElementReleaseNotesLink]]; + NSString *releaseNotesString = dict[SUAppcastElementReleaseNotesLink]; + if (releaseNotesString) { + self.releaseNotesURL = [NSURL URLWithString:releaseNotesString]; } else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that. self.releaseNotesURL = [NSURL URLWithString:self.itemDescription]; } else { diff --git a/Sparkle/SUAutomaticUpdateAlert.m b/Sparkle/SUAutomaticUpdateAlert.m index 4271e608..c1e24d7f 100644 --- a/Sparkle/SUAutomaticUpdateAlert.m +++ b/Sparkle/SUAutomaticUpdateAlert.m @@ -34,7 +34,7 @@ return self; } -- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; } +- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; } - (IBAction)installNow:(id)__unused sender { @@ -57,12 +57,12 @@ self.completionBlock = nil; } -- (NSImage *)applicationIcon +- (NSImage *__nonnull)applicationIcon { return [self.host icon]; } -- (NSString *)titleText +- (NSString *__nonnull)titleText { if ([self.updateItem isCriticalUpdate]) { diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 5da386a1..f7c3618d 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -100,7 +100,7 @@ typedef struct { return [self.bundle bundlePath]; } -- (NSString *)name +- (NSString *__nonnull)name { NSString *name; @@ -117,7 +117,7 @@ typedef struct { return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension]; } -- (NSString *)version +- (NSString *__nonnull)version { NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; if (!version || [version isEqualToString:@""]) @@ -125,7 +125,7 @@ typedef struct { return version; } -- (NSString *)displayVersion +- (NSString *__nonnull)displayVersion { NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; if (shortVersionString) @@ -134,7 +134,7 @@ typedef struct { return [self version]; // Fall back on the normal version string. } -- (NSImage *)icon +- (NSImage *__nonnull)icon { // Cache the application icon. NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"]; diff --git a/Sparkle/Sparkle.pch b/Sparkle/Sparkle.pch index ccd8c759..6d05189f 100644 --- a/Sparkle/Sparkle.pch +++ b/Sparkle/Sparkle.pch @@ -12,6 +12,6 @@ #import "SUConstants.h" #import "SUErrors.h" -#define SULocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", [NSBundle bundleWithIdentifier:SUBundleIdentifier] ? [NSBundle bundleWithIdentifier:SUBundleIdentifier] : [NSBundle mainBundle], comment) +#define SULocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", (NSBundle *__nonnull)([NSBundle bundleWithIdentifier:SUBundleIdentifier] ? [NSBundle bundleWithIdentifier:SUBundleIdentifier] : [NSBundle mainBundle]), comment) #endif