Was previously creating a new thread for every call to +userDidSignificantEvent, +appEnteredForeground, and +appLaunched, which is unnecessarily expensive (especially for apps calling userDidSignificantEvent often).
Use #ifs for APPIRATER_DEBUG instead of runtime check.
Use GCD instead of threads.
Was previously creating a new thread for every call to +userDidSignifica
ntEvent, +appEnteredForeground, and +appLaunched.
I just revised your version with this dispatch_once singleton:
I've been reading up on race conditions with older style singletons and I "believe" this style is safe, secure and thread safe.
#pragma mark GCD Singleton
static Appirater *appirater = nil;
if (appirater) return appirater;
static dispatch_once_t onceToken;
appirater = [[Appirater alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillResignActive) name:@"UIApplicationWillResignActiveNotification" object:nil];
Use GCD dispatch_once instead of @synchronized for +sharedInstance.
This is supposed to be faster, see e.g.
Good idea! Just changed it to use dispatch_once. Thanks!
np - I've been testing your commit the last few days and no problems - nice update!
Tweak: use UKKit constant instead of string.
I like the idea of using GCD, but I need to make sure Appirater remains compatible for developers who still need to deploy on iOS3 devices (myself included :-/ ).
@arashpayan - no problem, except Apple will be making that decision for you (meaning say around iOS 5.1 or 5.2, Apple will bump the min OS and remove 3.x from the list, for new apps). :-) Of course for Game center apps all these "rate my app" projects will no longer be needed in 5.x ( i'll be keeping it in my apps for non-game center users, which there are still a lot of)
+1, can we please use this? It's been 6 months, iOS 3 is barely relevant any more.
iOS 6 is now out... no one cares about the first iteration iPhone. Time to merge this into master? ;)