I do the following to put a time limit in the app for beta testing:
#ifdef BETA
NSString *compileDate = [NSString stringWithFormat:@"%s %s", __DATE__, __TIME__];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMM d yyyy HH:mm:ss"];
NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
[df setLocale:usLocale];
NSDate *aDate = [df dateFromString:compileDate];
NSDate *expires = [aDate dateByAddingTimeInterval:60 * 60 * 24 * 7]; // 7 days
NSDate *now = [NSDate date];
if ([now compare:expires] == NSOrderedDescending) {
NSAssert(0, @"Sorry, expired");
}
#endif
where BETA
is a compile flag I set only for adhoc builds.
I put this code in the applicationWillEnterForeground:
app delegate method.