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.
*/
@property (nonatomic, assign) id <BITCrashManagerDelegate> delegate;
@property (nonatomic, assign) id delegate;
///-----------------------------------------------------------------------------

View File

@ -69,7 +69,7 @@
@interface BITHockeyManager : NSObject {
@private
id<BITHockeyManagerDelegate> delegate;
id _delegate;
NSString *_appIdentifier;
BOOL _validAppIdentifier;
@ -96,16 +96,20 @@
Initializes the manager with a particular app identifier and delegate
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];
@see configureWithBetaIdentifier:liveIdentifier:delegate:
@see startManager
@see BITHockeyManagerDelegate
@see BITCrashManagerDelegate
@see BITUpdateManagerDelegate
@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.
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.
And also assign the class that implements the optional protocols `BITHockeyManagerDelegate`,
`BITCrashManagerDelegate` or `BITUpdateManagerDelegate`
[[BITHockeyManager sharedHockeyManager] configureWithBetaIdentifier:@"<AppIdentifierForBetaAppFromHockeyApp>"
liveIdentifier:@"<AppIdentifierForLiveAppFromHockeyApp>"
@ -121,11 +127,14 @@
@see configureWithIdentifier:delegate:
@see startManager
@see BITHockeyManagerDelegate
@see BITCrashManagerDelegate
@see BITUpdateManagerDelegate
@param betaIdentifier The app identifier for the _non_ app store (beta) 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 {
if ((self = [super init])) {
_updateURL = nil;
_delegate = nil;
_disableCrashManager = NO;
_disableUpdateManager = NO;
@ -96,7 +97,7 @@
[_crashManager release], _crashManager = nil;
[_updateManager release], _updateManager = nil;
delegate = nil;
_delegate = nil;
[super dealloc];
}
@ -104,16 +105,16 @@
#pragma mark - Public Instance Methods (Configuration)
- (void)configureWithIdentifier:(NSString *)newAppIdentifier delegate:(id)newDelegate {
delegate = newDelegate;
- (void)configureWithIdentifier:(NSString *)appIdentifier delegate:(id)delegate {
_delegate = delegate;
[_appIdentifier release];
_appIdentifier = [newAppIdentifier copy];
_appIdentifier = [appIdentifier copy];
[self initializeModules];
}
- (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id)newDelegate {
delegate = newDelegate;
- (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(NSString *)liveIdentifier delegate:(id)delegate {
_delegate = delegate;
[_appIdentifier release];
if ([self shouldUseLiveIdenfitier]) {
@ -179,8 +180,8 @@
- (BOOL)shouldUseLiveIdenfitier {
BOOL delegateResult = NO;
if ([delegate respondsToSelector:@selector(shouldUseLiveIdenfitier)]) {
delegateResult = [(NSObject <BITHockeyManagerDelegate>*)delegate shouldUseLiveIdenfitier];
if ([_delegate respondsToSelector:@selector(shouldUseLiveIdenfitier)]) {
delegateResult = [(NSObject <BITHockeyManagerDelegate>*)_delegate shouldUseLiveIdenfitier];
}
return (delegateResult) || (_appStoreEnvironment);
@ -196,9 +197,11 @@
if (_validAppIdentifier) {
BITHockeyLog(@"Setup CrashManager");
_crashManager = [[BITCrashManager alloc] initWithAppIdentifier:_appIdentifier];
_crashManager.delegate = _delegate;
BITHockeyLog(@"Setup UpdateManager");
_updateManager = [[BITUpdateManager alloc] initWithAppIdentifier:_appIdentifier isAppStoreEnvironemt:_appStoreEnvironment];
_crashManager.delegate = _delegate;
// Only if JMC is part of the project
if ([[self class] isJMCPresent]) {

View File

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