Add delegate as parameter to SUUpdater's initializer

This commit is contained in:
Zorg committed 2016-03-01 22:22:05 -05:00
1 parent efac2acf57
commit 1da4ee961c
3 files changed
+12 -9

No files matched your search

+2 -2
View File
@@ -26,11 +26,11 @@
*/
SU_EXPORT @interface SUUpdater : NSObject
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)delegate;
@property (weak) id<SUUpdaterDelegate> delegate;
@property (nonatomic, readonly) id<SUUserDriver> userDriver;
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver;
@property (readonly, strong) NSBundle *hostBundle;
@property (strong, readonly) NSBundle *sparkleBundle;
+3 -1
View File
@@ -53,7 +53,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize sparkleBundle;
@synthesize decryptionPassword;
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)theDelegate
{
self = [super init];
@@ -68,6 +68,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
_userDriver = userDriver;
delegate = theDelegate;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
[self startUpdateCycle];
+7 -6
View File
@@ -33,21 +33,22 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
// We don't want the updater to start its updating cycle before the app has finished launching
// If this is instantiated in a nib, the runloop may not be ready
// Furthermore, this delay allows setting the updater and user driver delegates before the updater initializes
[self performSelector:@selector(instantiateUpdater) withObject:nil afterDelay:0];
}
return self;
}
- (void)dealloc
{
[self unregisterAsObserver];
}
- (void)instantiateUpdater
{
NSBundle *hostBundle = [NSBundle mainBundle];
id <SUUserDriver> driver = [[SUSparkleUserDriver alloc] initWithHostBundle:hostBundle delegate:nil];
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:driver];
}
- (void)dealloc
{
[self unregisterAsObserver];
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:driver delegate:nil];
}
- (IBAction)checkForUpdates:(id)__unused sender