diff --git a/Sparkle/SPUStandardUpdaterController.h b/Sparkle/SPUStandardUpdaterController.h index f50406e4..2448de41 100644 --- a/Sparkle/SPUStandardUpdaterController.h +++ b/Sparkle/SPUStandardUpdaterController.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN /*! A controller class that instantiates a SPUUpdater and allows binding UI to it. - This class is meant to be instantiated in a nib. When doing so, the controller's updater targets the application's main bundle, + This class can be instantiated in a nib or created using initWithUpdaterDelegate:userDriverDelegate:. The controller's updater targets the application's main bundle and uses Sparkle's standard user interface. Typically, this class is used by sticking it as a custom NSObject subclass in an Interface Builder nib (probably in MainMenu). The controller creates an SPUUpdater instance and allows hooking up the check for updates action and menu item validation. It also allows hooking @@ -67,6 +67,16 @@ SU_EXPORT @interface SPUStandardUpdaterController : NSObject */ @property (nonatomic, readonly, nullable) id userDriver; +/*! + Use initWithUpdaterDelegate:userDriverDelegate: instead. + */ +- (instancetype)init NS_UNAVAILABLE; + +/*! + Create a new SPUStandardUpdaterController programmatically. + */ +- (instancetype)initWithUpdaterDelegate:(nullable id)updaterDelegate userDriverDelegate:(nullable id)userDriverDelegate; + /*! Explicitly checks for updates and displays a progress dialog while doing so. diff --git a/Sparkle/SPUStandardUpdaterController.m b/Sparkle/SPUStandardUpdaterController.m index b6efb74c..d079c3f0 100644 --- a/Sparkle/SPUStandardUpdaterController.m +++ b/Sparkle/SPUStandardUpdaterController.m @@ -36,6 +36,22 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults // awakeFromNib might be called more than once; guard against that // We have to use awakeFromNib otherwise the delegate outlets may not be connected yet, // and we aren't a proper window or view controller, so we don't have a proper "did load" point + [self initializeUpdater]; +} + +- (instancetype)initWithUpdaterDelegate:(nullable id)updaterDelegate userDriverDelegate:(nullable id)userDriverDelegate +{ + if ((self = [super init])) { + _updaterDelegate = updaterDelegate; + _userDriverDelegate = userDriverDelegate; + + [self initializeUpdater]; + } + return self; +} + +- (void)initializeUpdater +{ if (!self.initializedUpdater) { self.initializedUpdater = YES;