From 9ee8a6d314403ed01e8a5dc5d45cddacd398e789 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 2 Mar 2016 01:15:10 -0500 Subject: [PATCH] Wrap initializer with standard if self != nil check --- Sparkle/SUUpdater.m | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index e4ab5330..87f9eaf8 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -56,25 +56,27 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification - (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id )userDriver delegate:(id )theDelegate { self = [super init]; - - // Use explicit class to use the correct bundle even when subclassed - self.sparkleBundle = [NSBundle bundleForClass:[SUUpdater class]]; - if (!self.sparkleBundle) { - SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to"); - return nil; + + if (self != nil) { + // Use explicit class to use the correct bundle even when subclassed + self.sparkleBundle = [NSBundle bundleForClass:[SUUpdater class]]; + if (!self.sparkleBundle) { + SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to"); + return nil; + } + + host = [[SUHost alloc] initWithBundle:bundle]; + + _userDriver = userDriver; + + delegate = theDelegate; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil]; + + // This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that + // We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet + [self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1]; } - - host = [[SUHost alloc] initWithBundle:bundle]; - - _userDriver = userDriver; - - delegate = theDelegate; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil]; - - // This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that - // We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet - [self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1]; return self; }