From 67ad9477a32093c959225b180b9c525cf3d9b6df Mon Sep 17 00:00:00 2001 From: Mikhail Seriukov Date: Thu, 8 Oct 2015 23:03:44 +0600 Subject: [PATCH] Fixed wrong delegate setting problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes problem where you can’t set delegate to a different value after sharedInstance called once. --- Appirater.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Appirater.m b/Appirater.m index 951b8920..58a790a4 100644 --- a/Appirater.m +++ b/Appirater.m @@ -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 _delegate; -#else - __weak static id _delegate; -#endif static BOOL _usesAnimation = TRUE; static UIStatusBarStyle _statusBarStyle; static BOOL _modalOpen = false; @@ -141,7 +136,7 @@ + (void) setDebug:(BOOL)debug { _debug = debug; } + (void)setDelegate:(id)delegate{ - _delegate = delegate; + [Appirater sharedInstance].delegate = delegate; } + (void)setUsesAnimation:(BOOL)animation { _usesAnimation = animation; @@ -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]; }); @@ -270,7 +264,7 @@ + (Appirater*)sharedInstance { - (void)showRatingAlert:(BOOL)displayRateLaterButton { UIAlertView *alertView = nil; - id delegate = _delegate; + id delegate = self.delegate; if(delegate && [delegate respondsToSelector:@selector(appiraterShouldDisplayAlert:)] && ![delegate appiraterShouldDisplayAlert:self]) { return; @@ -669,7 +663,7 @@ + (void)rateApp { - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - id delegate = _delegate; + id delegate = self.delegate; switch (buttonIndex) { case 0: