You could see what the problem is by simply doing NSLog(@"userSettings = %@", userSettings); at the top of this method. Did you try that?
+(BOOL)okToRequestRatingUsingCount:(int)count
{
NSLog(@"userSettings = %@", userSettings);
int curVersion = [[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] intValue]; // Will work without error
NSNumber *lastVerRated = [userSettings objectForKey:RateLastVersionRated]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash
int lastVersionRated = (lastVerRated != nil) ? [lastVerRated intValue] : 0; // If userSettings == nil you'll get 0 but no crash
NSNumber *ratePromptCnt = [userSettings objectForKey:RatePromptCounter]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash
int rateCounter = (ratePromptCnt != nil) ? [ratePromptCnt intValue] : 1; // If userSettings == nil you'll get 1 but no crash
NSDate *dateLastCounterIncrement = [userSettings objectForKey:RatePromptCounterLastDateIncrement]; // Will work, but might return nil if userSettings has been dealloc'd, but no crash
if(!dateLastCounterIncrement) { // If userSettings has been dealloc'd, this will execute
dateLastCounterIncrement = [NSDate date];
[userSettings setObject:dateLastCounterIncrement forKey:RatePromptCounterLastDateIncrement]; // If userSettings is nil, this will crash
}
if(curVersion > lastVersionRated) {
if(rateCounter > count)
return YES;
else {
// Increment the counter only once a day
if([[NSDate date] timeIntervalSinceDate:dateLastCounterIncrement] > (3600 * 24)) {
rateCounter++;
[userSettings setObject:[NSNumber numberWithInt:rateCounter] forKey:RatePromptCounter]; // If userSettings is nil, this will crash
}
}
}
return NO;
}