Set the submodules delegates to the same delegate defined by the initial configure initialization.

The delegates can still be access and set directly, if the dev wants to have different classes implementing them.
For the general user this improves the ease of setup, because the submodules delegates don't have to be set specifically and by setting the delegate protocols in the header the missing required delegates will still be shown as warning
This commit is contained in:
Andreas Linde 2012-08-10 15:45:32 +02:00
parent 198def34df
commit e69a32a676
4 changed files with 28 additions and 16 deletions

View File

@ -103,7 +103,7 @@ static NSString *kBITCrashManagerStatus = @"BITCrashManagerStatus";
/** /**
Sets the optional `BITCrashManagerDelegate` delegate. Sets the optional `BITCrashManagerDelegate` delegate.
*/ */
@property (nonatomic, assign) id <BITCrashManagerDelegate> delegate; @property (nonatomic, assign) id delegate;
///----------------------------------------------------------------------------- ///-----------------------------------------------------------------------------

View File

@ -69,7 +69,7 @@
@interface BITHockeyManager : NSObject { @interface BITHockeyManager : NSObject {
@private @private
id<BITHockeyManagerDelegate> delegate; id _delegate;
NSString *_appIdentifier; NSString *_appIdentifier;
BOOL _validAppIdentifier; BOOL _validAppIdentifier;
@ -96,16 +96,20 @@
Initializes the manager with a particular app identifier and delegate Initializes the manager with a particular app identifier and delegate
Initialize the manager with a HockeyApp app identifier and assign the class that Initialize the manager with a HockeyApp app identifier and assign the class that
implements the optional BITHockeyManagerDelegate protocol. implements the optional protocols `BITHockeyManagerDelegate`, `BITCrashManagerDelegate` or
`BITUpdateManagerDelegate`.
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"<AppIdentifierFromHockeyApp>" delegate:nil]; [[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"<AppIdentifierFromHockeyApp>" delegate:nil];
@see configureWithBetaIdentifier:liveIdentifier:delegate: @see configureWithBetaIdentifier:liveIdentifier:delegate:
@see startManager @see startManager
@see BITHockeyManagerDelegate
@see BITCrashManagerDelegate
@see BITUpdateManagerDelegate
@param appIdentifier The app identifier that should be used. @param appIdentifier The app identifier that should be used.
@param delegate `nil` or the class implementing the option BITHockeyManagerDelegate protocol @param delegate `nil` or the class implementing the option protocols
*/ */
- (void)configureWithIdentifier:(NSString *)appIdentifier delegate:(id<BITHockeyManagerDelegate>)delegate; - (void)configureWithIdentifier:(NSString *)appIdentifier delegate:(id)delegate;
/** /**
@ -114,6 +118,8 @@
Initialize the manager with different HockeyApp app identifiers for beta and live usage. Initialize the manager with different HockeyApp app identifiers for beta and live usage.
All modules will automatically detect if the app is running in the App Store and use All modules will automatically detect if the app is running in the App Store and use
the live app identifier for that. In all other cases it will use the beta app identifier. the live app identifier for that. In all other cases it will use the beta app identifier.
And also assign the class that implements the optional protocols `BITHockeyManagerDelegate`,
`BITCrashManagerDelegate` or `BITUpdateManagerDelegate`
[[BITHockeyManager sharedHockeyManager] configureWithBetaIdentifier:@"<AppIdentifierForBetaAppFromHockeyApp>" [[BITHockeyManager sharedHockeyManager] configureWithBetaIdentifier:@"<AppIdentifierForBetaAppFromHockeyApp>"
liveIdentifier:@"<AppIdentifierForLiveAppFromHockeyApp>" liveIdentifier:@"<AppIdentifierForLiveAppFromHockeyApp>"
@ -121,11 +127,14 @@
@see configureWithIdentifier:delegate: @see configureWithIdentifier:delegate:
@see startManager @see startManager
@see BITHockeyManagerDelegate
@see BITCrashManagerDelegate
@see BITUpdateManagerDelegate
@param betaIdentifier The app identifier for the _non_ app store (beta) configurations @param betaIdentifier The app identifier for the _non_ app store (beta) configurations
@param liveIdentifier The app identifier for the app store configurations. @param liveIdentifier The app identifier for the app store configurations.
@param delegate `nil` or the implementing the optional BITHockeyManagerDelegate protocol @param delegate `nil` or the class implementing the optional protocols
*/ */
- (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id<BITHockeyManagerDelegate>)delegate; - (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id)delegate;
/** /**

View File

@ -67,6 +67,7 @@
- (id) init { - (id) init {
if ((self = [super init])) { if ((self = [super init])) {
_updateURL = nil; _updateURL = nil;
_delegate = nil;
_disableCrashManager = NO; _disableCrashManager = NO;
_disableUpdateManager = NO; _disableUpdateManager = NO;
@ -96,7 +97,7 @@
[_crashManager release], _crashManager = nil; [_crashManager release], _crashManager = nil;
[_updateManager release], _updateManager = nil; [_updateManager release], _updateManager = nil;
delegate = nil; _delegate = nil;
[super dealloc]; [super dealloc];
} }
@ -104,16 +105,16 @@
#pragma mark - Public Instance Methods (Configuration) #pragma mark - Public Instance Methods (Configuration)
- (void)configureWithIdentifier:(NSString *)newAppIdentifier delegate:(id)newDelegate { - (void)configureWithIdentifier:(NSString *)appIdentifier delegate:(id)delegate {
delegate = newDelegate; _delegate = delegate;
[_appIdentifier release]; [_appIdentifier release];
_appIdentifier = [newAppIdentifier copy]; _appIdentifier = [appIdentifier copy];
[self initializeModules]; [self initializeModules];
} }
- (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id)newDelegate { - (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id)delegate {
delegate = newDelegate; _delegate = delegate;
[_appIdentifier release]; [_appIdentifier release];
if ([self shouldUseLiveIdenfitier]) { if ([self shouldUseLiveIdenfitier]) {
@ -179,8 +180,8 @@
- (BOOL)shouldUseLiveIdenfitier { - (BOOL)shouldUseLiveIdenfitier {
BOOL delegateResult = NO; BOOL delegateResult = NO;
if ([delegate respondsToSelector:@selector(shouldUseLiveIdenfitier)]) { if ([_delegate respondsToSelector:@selector(shouldUseLiveIdenfitier)]) {
delegateResult = [(NSObject <BITHockeyManagerDelegate>*)delegate shouldUseLiveIdenfitier]; delegateResult = [(NSObject <BITHockeyManagerDelegate>*)_delegate shouldUseLiveIdenfitier];
} }
return (delegateResult) || (_appStoreEnvironment); return (delegateResult) || (_appStoreEnvironment);
@ -196,9 +197,11 @@
if (_validAppIdentifier) { if (_validAppIdentifier) {
BITHockeyLog(@"Setup CrashManager"); BITHockeyLog(@"Setup CrashManager");
_crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier]; _crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier];
_crashManager.delegate = _delegate;
BITHockeyLog(@"Setup UpdateManager"); BITHockeyLog(@"Setup UpdateManager");
_updateManager = [[BITUpdateManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironemt:_appStoreEnvironment]; _updateManager = [[BITUpdateManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironemt:_appStoreEnvironment];
_crashManager.delegate = _delegate;
// Only if JMC is part of the project // Only if JMC is part of the project
if ([[self class] isJMCPresent]) { if ([[self class] isJMCPresent]) {

View File

@ -109,7 +109,7 @@ typedef enum {
application, it is _REQUIRED_ to set this delegate and implement application, it is _REQUIRED_ to set this delegate and implement
`[BITUpdateManagerDelegate customDeviceIdentifierForUpdateManager:]`! `[BITUpdateManagerDelegate customDeviceIdentifierForUpdateManager:]`!
*/ */
@property (nonatomic, assign) id <BITUpdateManagerDelegate> delegate; @property (nonatomic, assign) id delegate;
///----------------------------------------------------------------------------- ///-----------------------------------------------------------------------------