From 16032b9c614522f11cf200ee03aeb35937389be8 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 15 May 2017 17:03:46 -0400 Subject: [PATCH] strongSelf per CR // FREEBIE --- Signal/src/ViewControllers/MessagesViewController.m | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/MessagesViewController.m b/Signal/src/ViewControllers/MessagesViewController.m index 012bd16ed..361cf70d5 100644 --- a/Signal/src/ViewControllers/MessagesViewController.m +++ b/Signal/src/ViewControllers/MessagesViewController.m @@ -3108,13 +3108,20 @@ typedef enum : NSUInteger { - (void)requestRecordingVoiceMemo { OWSAssert([NSThread isMainThread]); + + __weak typeof(self) weakSelf = self; [[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted) { dispatch_async(dispatch_get_main_queue(), ^{ + __strong typeof(self) strongSelf = weakSelf; + if (!strongSelf) { + return; + } + if (granted) { - [self startRecordingVoiceMemo]; + [strongSelf startRecordingVoiceMemo]; } else { DDLogInfo(@"%@ we do not have recording permission.", self.tag); - [self cancelVoiceMemo]; + [strongSelf cancelVoiceMemo]; [OWSAlerts showNoMicrophonePermissionAlert]; } });