Allow delegate methods that return an object to return nil

Returning nil from these delegate methods is equivalent to not implementing the delegate method. The caller should be able to make this kind of decision when implementing an optional delegate method.
This commit is contained in:
Zorg committed 2016-12-25 18:41:38 -05:00
1 parent 578e78876c
commit 796967cf24
2 files changed
+16 -5

No files matched your search

+10 -3
View File
@@ -162,11 +162,15 @@
if ([[self.updater delegate] respondsToSelector:@selector(bestValidUpdateInAppcast:forUpdater:)]) // Does the delegate want to handle it?
{
item = [[self.updater delegate] bestValidUpdateInAppcast:ac forUpdater:(id)self.updater];
}
if (item != nil) // Does the delegate want to handle it?
{
if ([item isDeltaUpdate]) {
self.nonDeltaUpdateItem = [[self.updater delegate] bestValidUpdateInAppcast:[ac copyWithoutDeltaUpdates] forUpdater:(id)self.updater];
}
}
else // If not, we'll take care of it ourselves.
}
else // If not, we'll take care of it ourselves.
{
// Find the best supported update
SUAppcastItem *deltaUpdateItem = nil;
@@ -525,7 +529,10 @@
NSString *pathToRelaunch = [self.host bundlePath];
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:(id)self.updater];
NSString *delegateRelaunchPath = [updaterDelegate pathToRelaunchForUpdater:(id)self.updater];
if (delegateRelaunchPath != nil) {
pathToRelaunch = delegateRelaunchPath;
}
}
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
+6 -2
View File
@@ -435,8 +435,12 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// A value in the user defaults overrides one in the Info.plist (so preferences panels can be created wherein users choose between beta / release feeds).
NSString *appcastString = [self.host objectForKey:SUFeedURLKey];
if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)])
appcastString = [self.delegate feedURLStringForUpdater:self];
if ([self.delegate respondsToSelector:@selector(feedURLStringForUpdater:)]) {
NSString *delegateAppcastString = [self.delegate feedURLStringForUpdater:self];
if (delegateAppcastString != nil) {
appcastString = delegateAppcastString;
}
}
if (!appcastString) // Can't find an appcast string!
[NSException raise:@"SUNoFeedURL" format:@"You must specify the URL of the appcast as the %@ key in either the Info.plist or the user defaults!", SUFeedURLKey];
NSCharacterSet *quoteSet = [NSCharacterSet characterSetWithCharactersInString:@"\"\'"]; // Some feed publishers add quotes; strip 'em.