Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong delegate setting problem #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions Appirater.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@
static NSInteger _significantEventsUntilPrompt = -1;
static double _timeBeforeReminding = 1;
static BOOL _debug = NO;
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0
static id<AppiraterDelegate> _delegate;
#else
__weak static id<AppiraterDelegate> _delegate;
#endif
static BOOL _usesAnimation = TRUE;
static UIStatusBarStyle _statusBarStyle;
static BOOL _modalOpen = false;
Expand Down Expand Up @@ -141,7 +136,7 @@ + (void) setDebug:(BOOL)debug {
_debug = debug;
}
+ (void)setDelegate:(id<AppiraterDelegate>)delegate{
_delegate = delegate;
[Appirater sharedInstance].delegate = delegate;
}
+ (void)setUsesAnimation:(BOOL)animation {
_usesAnimation = animation;
Expand Down Expand Up @@ -259,7 +254,6 @@ + (Appirater*)sharedInstance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
appirater = [[Appirater alloc] init];
appirater.delegate = _delegate;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive) name:
UIApplicationWillResignActiveNotification object:nil];
});
Expand All @@ -270,7 +264,7 @@ + (Appirater*)sharedInstance {

- (void)showRatingAlert:(BOOL)displayRateLaterButton {
UIAlertView *alertView = nil;
id <AppiraterDelegate> delegate = _delegate;
id <AppiraterDelegate> delegate = self.delegate;

if(delegate && [delegate respondsToSelector:@selector(appiraterShouldDisplayAlert:)] && ![delegate appiraterShouldDisplayAlert:self]) {
return;
Expand Down Expand Up @@ -669,7 +663,7 @@ + (void)rateApp {
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

id <AppiraterDelegate> delegate = _delegate;
id <AppiraterDelegate> delegate = self.delegate;

switch (buttonIndex) {
case 0:
Expand Down