mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-24 09:06:30 +00:00
Merge pull request #194 from 0xced/clean-optional-delegate-calls
Remove unnecessary nil checking before calling `respondsToSelector:`
This commit is contained in:
commit
ff397e876b
@ -596,8 +596,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
}
|
||||
#endif
|
||||
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userIDForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userIDForHockeyManager:componentManager:)]) {
|
||||
userID = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userIDForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self] ?: @"";
|
||||
@ -615,14 +614,13 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
// first check the global keychain storage
|
||||
NSString *username = [self stringValueFromKeychainForKey:kBITHockeyMetaUserName] ?: @"";
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(userNameForCrashManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(userNameForCrashManager:)]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
username = [self.delegate userNameForCrashManager:self] ?: @"";
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userNameForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userNameForHockeyManager:componentManager:)]) {
|
||||
username = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userNameForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self] ?: @"";
|
||||
@ -652,14 +650,13 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
}
|
||||
#endif
|
||||
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(userEmailForCrashManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(userEmailForCrashManager:)]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
useremail = [self.delegate userEmailForCrashManager:self] ?: @"";
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userEmailForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userEmailForHockeyManager:componentManager:)]) {
|
||||
useremail = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userEmailForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self] ?: @"";
|
||||
@ -754,12 +751,12 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
[self addStringValueToKeychain:[self userEmailForCrashReport] forKey:[NSString stringWithFormat:@"%@.%@", filename, kBITCrashMetaUserEmail]];
|
||||
[self addStringValueToKeychain:[self userIDForCrashReport] forKey:[NSString stringWithFormat:@"%@.%@", filename, kBITCrashMetaUserID]];
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(applicationLogForCrashManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(applicationLogForCrashManager:)]) {
|
||||
applicationLog = [self.delegate applicationLogForCrashManager:self] ?: @"";
|
||||
}
|
||||
[metaDict setObject:applicationLog forKey:kBITCrashMetaApplicationLog];
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(attachmentForCrashManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(attachmentForCrashManager:)]) {
|
||||
BITHockeyAttachment *attachment = [self.delegate attachmentForCrashManager:self];
|
||||
|
||||
if (attachment && attachment.hockeyAttachmentData) {
|
||||
@ -781,7 +778,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
- (BOOL)handleUserInput:(BITCrashManagerUserInput)userInput withUserProvidedMetaData:(BITCrashMetaData *)userProvidedMetaData {
|
||||
switch (userInput) {
|
||||
case BITCrashManagerUserInputDontSend:
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
||||
[self.delegate crashManagerWillCancelSendingCrashReport:self];
|
||||
}
|
||||
|
||||
@ -802,7 +799,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
_crashManagerStatus = BITCrashManagerStatusAutoSend;
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:_crashManagerStatus forKey:kBITCrashManagerStatus];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReportsAlways:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReportsAlways:)]) {
|
||||
[self.delegate crashManagerWillSendCrashReportsAlways:self];
|
||||
}
|
||||
|
||||
@ -957,7 +954,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
return YES;
|
||||
} else {
|
||||
if (_didCrashInLastSession) {
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
|
||||
[self.delegate crashManagerWillCancelSendingCrashReport:self];
|
||||
}
|
||||
|
||||
@ -1024,7 +1021,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
[self sendNextCrashReport];
|
||||
} else if (_crashManagerStatus != BITCrashManagerStatusAutoSend && notApprovedReportFilename) {
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillShowSubmitCrashReportAlert:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerWillShowSubmitCrashReportAlert:)]) {
|
||||
[self.delegate crashManagerWillShowSubmitCrashReportAlert:self];
|
||||
}
|
||||
|
||||
@ -1172,8 +1169,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
if (!didAppSwitchToBackgroundSafely) {
|
||||
BOOL considerReport = YES;
|
||||
|
||||
if (self.delegate &&
|
||||
[self.delegate respondsToSelector:@selector(considerAppNotTerminatedCleanlyReportForCrashManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(considerAppNotTerminatedCleanlyReportForCrashManager:)]) {
|
||||
considerReport = [self.delegate considerAppNotTerminatedCleanlyReportForCrashManager:self];
|
||||
}
|
||||
|
||||
@ -1551,8 +1547,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
error:&theError];
|
||||
BITHockeyLog(@"INFO: Received API response: %@", response);
|
||||
|
||||
if (self.delegate != nil &&
|
||||
[self.delegate respondsToSelector:@selector(crashManagerDidFinishSendingCrashReport:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerDidFinishSendingCrashReport:)]) {
|
||||
[self.delegate crashManagerDidFinishSendingCrashReport:self];
|
||||
}
|
||||
|
||||
@ -1578,8 +1573,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
}
|
||||
|
||||
if (theError) {
|
||||
if (self.delegate != nil &&
|
||||
[self.delegate respondsToSelector:@selector(crashManager:didFailWithError:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManager:didFailWithError:)]) {
|
||||
[self.delegate crashManager:self didFailWithError:theError];
|
||||
}
|
||||
|
||||
@ -1642,7 +1636,7 @@ static void uncaught_cxx_exception_handler(const BITCrashUncaughtCXXExceptionInf
|
||||
[self.hockeyAppClient enqeueHTTPOperation:operation];
|
||||
}
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReport:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(crashManagerWillSendCrashReport:)]) {
|
||||
[self.delegate crashManagerWillSendCrashReport:self];
|
||||
}
|
||||
|
||||
|
||||
@ -467,9 +467,9 @@
|
||||
}
|
||||
|
||||
- (void)dismissWithResult:(BITFeedbackComposeResult) result {
|
||||
if(self.delegate && [self.delegate respondsToSelector:@selector(feedbackComposeViewController:didFinishWithResult:)]) {
|
||||
if([self.delegate respondsToSelector:@selector(feedbackComposeViewController:didFinishWithResult:)]) {
|
||||
[self.delegate feedbackComposeViewController:self didFinishWithResult:result];
|
||||
} else if (self.delegate && [self.delegate respondsToSelector:@selector(feedbackComposeViewControllerDidFinish:)]) {
|
||||
} else if ([self.delegate respondsToSelector:@selector(feedbackComposeViewControllerDidFinish:)]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
[self.delegate feedbackComposeViewControllerDidFinish:self];
|
||||
|
||||
@ -386,10 +386,9 @@
|
||||
[self dismissViewControllerAnimated:YES completion:^(void){}];
|
||||
}
|
||||
|
||||
if (self.manager.delegate &&
|
||||
[self.manager.delegate respondsToSelector:@selector(feedbackComposeViewController:didFinishWithResult:)]) {
|
||||
if ([self.manager.delegate respondsToSelector:@selector(feedbackComposeViewController:didFinishWithResult:)]) {
|
||||
[self.manager.delegate feedbackComposeViewController:composeViewController didFinishWithResult:composeResult];
|
||||
} else if (self.manager.delegate && [self.manager.delegate respondsToSelector:@selector(feedbackComposeViewControllerDidFinish:)]) {
|
||||
} else if ([self.manager.delegate respondsToSelector:@selector(feedbackComposeViewControllerDidFinish:)]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
[self.manager.delegate feedbackComposeViewControllerDidFinish:composeViewController];
|
||||
|
||||
@ -279,8 +279,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
|
||||
- (BOOL)allowFetchingNewMessages {
|
||||
BOOL fetchNewMessages = YES;
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(allowAutomaticFetchingForNewFeedbackForManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(allowAutomaticFetchingForNewFeedbackForManager:)]) {
|
||||
fetchNewMessages = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
allowAutomaticFetchingForNewFeedbackForManager:self];
|
||||
}
|
||||
@ -310,8 +309,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
|
||||
NSString *userID = [self stringValueFromKeychainForKey:kBITHockeyMetaUserID];
|
||||
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userIDForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userIDForHockeyManager:componentManager:)]) {
|
||||
userID = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userIDForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self];
|
||||
@ -330,8 +328,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
|
||||
NSString *userName = [self stringValueFromKeychainForKey:kBITHockeyMetaUserName];
|
||||
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userNameForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userNameForHockeyManager:componentManager:)]) {
|
||||
userName = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userNameForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self];
|
||||
@ -351,8 +348,7 @@ NSString *const kBITFeedbackUpdateAttachmentThumbnail = @"BITFeedbackUpdateAttac
|
||||
|
||||
NSString *userEmail = [self stringValueFromKeychainForKey:kBITHockeyMetaUserEmail];
|
||||
|
||||
if ([BITHockeyManager sharedHockeyManager].delegate &&
|
||||
[[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userEmailForHockeyManager:componentManager:)]) {
|
||||
if ([[BITHockeyManager sharedHockeyManager].delegate respondsToSelector:@selector(userEmailForHockeyManager:componentManager:)]) {
|
||||
userEmail = [[BITHockeyManager sharedHockeyManager].delegate
|
||||
userEmailForHockeyManager:[BITHockeyManager sharedHockeyManager]
|
||||
componentManager:self];
|
||||
|
||||
@ -293,7 +293,7 @@
|
||||
}
|
||||
|
||||
if ([self isUpdateAvailable]) {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(detectedUpdateFromStoreUpdateManager:newVersion:storeURL:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(detectedUpdateFromStoreUpdateManager:newVersion:storeURL:)]) {
|
||||
[self.delegate detectedUpdateFromStoreUpdateManager:self newVersion:_newStoreVersion storeURL:[NSURL URLWithString:_appStoreURLString]];
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
// we only care about iOS 8 or later
|
||||
if (bit_isPreiOS8Environment()) return;
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(updateManagerWillExitApp:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(updateManagerWillExitApp:)]) {
|
||||
[self.delegate updateManagerWillExitApp:self];
|
||||
}
|
||||
|
||||
@ -220,7 +220,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
|
||||
BOOL shouldShowDefaultAlert = YES;
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(shouldDisplayExpiryAlertForUpdateManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(shouldDisplayExpiryAlertForUpdateManager:)]) {
|
||||
shouldShowDefaultAlert = [self.delegate shouldDisplayExpiryAlertForUpdateManager:self];
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
_blockingScreenMessage = [NSString stringWithFormat:BITHockeyLocalizedString(@"UpdateExpired"), appName];
|
||||
[self showBlockingScreen:_blockingScreenMessage image:@"authorize_denied.png"];
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(didDisplayExpiryAlertForUpdateManager:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(didDisplayExpiryAlertForUpdateManager:)]) {
|
||||
[self.delegate didDisplayExpiryAlertForUpdateManager:self];
|
||||
}
|
||||
|
||||
@ -767,7 +767,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
NSString *iOSUpdateURL = [NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@", bit_URLEncodedString(hockeyAPIURL)];
|
||||
|
||||
// Notify delegate of update intent before placing the call
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(willStartDownloadAndUpdate:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(willStartDownloadAndUpdate:)]) {
|
||||
[self.delegate willStartDownloadAndUpdate:self];
|
||||
}
|
||||
|
||||
@ -790,7 +790,7 @@ typedef NS_ENUM(NSInteger, BITUpdateAlertViewTag) {
|
||||
|
||||
BITHockeyLog(@"INFO: Starting UpdateManager");
|
||||
|
||||
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(updateManagerShouldSendUsageData:)]) {
|
||||
if ([self.delegate respondsToSelector:@selector(updateManagerShouldSendUsageData:)]) {
|
||||
_sendUsageData = [self.delegate updateManagerShouldSendUsageData:self];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user