diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-12-13 11:10:16 -0800 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-12-13 11:10:16 -0800 |
commit | e8f40c6dcd3b3cdfd80da33b75fc571b30ee5d7b (patch) | |
tree | b25e26f1bce989019641a14d46f2e19ad0a166d3 | |
parent | b066606e8a06957ee6f1607b02e7035d2cc285d2 (diff) | |
download | sdl_ios-hotfix/issue_481.tar.gz |
Improved readability for nil-checks.hotfix/issue_481
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.m | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m index aea83d2be..63321f134 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -145,10 +145,10 @@ NS_ASSUME_NONNULL_BEGIN typeof(weakSelf) strongSelf = weakSelf; // If success, we will get an ACK or NACK, so those methods will handle calling the video block if (!success) { - if (strongSelf.videoStartBlock != nil) { - strongSelf.videoStartBlock(NO, NO, error); - strongSelf.videoStartBlock = nil; - } + if (strongSelf.videoStartBlock == nil) { return; } + + strongSelf.videoStartBlock(NO, NO, error); + strongSelf.videoStartBlock = nil; } }]; } else { @@ -182,10 +182,10 @@ NS_ASSUME_NONNULL_BEGIN typeof(weakSelf) strongSelf = weakSelf; // If this passes, we will get an ACK or NACK, so those methods will handle calling the audio block if (!success) { - if (strongSelf.audioStartBlock != nil) { - strongSelf.audioStartBlock(NO, NO, error); - strongSelf.audioStartBlock = nil; - } + if (strongSelf.audioStartBlock == nil) { return; } + + strongSelf.audioStartBlock(NO, NO, error); + strongSelf.audioStartBlock = nil; } }]; } else { @@ -281,10 +281,11 @@ NS_ASSUME_NONNULL_BEGIN case SDLServiceType_Audio: { self.audioSessionConnected = YES; self.audioSessionEncrypted = header.encrypted; - if (self.audioStartBlock != nil) { - self.audioStartBlock(YES, header.encrypted, nil); - self.audioStartBlock = nil; - } + + if (self.audioStartBlock == nil) { return; } + + self.audioStartBlock(YES, header.encrypted, nil); + self.audioStartBlock = nil; } break; case SDLServiceType_Video: { NSError *error = nil; @@ -294,21 +295,21 @@ NS_ASSUME_NONNULL_BEGIN [self sdl_teardownCompressionSession]; [self.protocol endServiceWithType:SDLServiceType_Video]; - if (self.videoStartBlock != nil) { - self.videoStartBlock(NO, header.encrypted, error); - self.videoStartBlock = nil; - } - + if (self.videoStartBlock == nil) { return; } + + self.videoStartBlock(NO, header.encrypted, error); + self.videoStartBlock = nil; + return; } self.videoSessionConnected = YES; self.videoSessionEncrypted = header.encrypted; - if (self.videoStartBlock != nil) { - self.videoStartBlock(YES, header.encrypted, nil); - self.videoStartBlock = nil; - } + if (self.videoStartBlock == nil) { return; } + + self.videoStartBlock(YES, header.encrypted, nil); + self.videoStartBlock = nil; } break; default: break; } @@ -319,18 +320,18 @@ NS_ASSUME_NONNULL_BEGIN case SDLServiceType_Audio: { NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaAudio code:SDLStreamingAudioErrorHeadUnitNACK userInfo:nil]; - if (self.audioStartBlock != nil) { - self.audioStartBlock(NO, NO, error); - self.audioStartBlock = nil; - } + if (self.audioStartBlock == nil) { return; } + + self.audioStartBlock(NO, NO, error); + self.audioStartBlock = nil; } break; case SDLServiceType_Video: { NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorHeadUnitNACK userInfo:nil]; - if (self.videoStartBlock != nil) { - self.videoStartBlock(NO, NO, error); - self.videoStartBlock = nil; - } + if (self.videoStartBlock == nil) { return; } + + self.videoStartBlock(NO, NO, error); + self.videoStartBlock = nil; } break; default: break; } |