0
我只想知道如何做一个平均或一天倒计数?我做了一些搜索谷歌,但我得到了一些信息,使这个应用程序,他们告诉我应该使用NSDate和NSCalendar.however我想存储所有信息和用户可以加载时重新打开应用程序,我应该使用SQLite或核心数据?感谢iphone倒数事件
我只想知道如何做一个平均或一天倒计数?我做了一些搜索谷歌,但我得到了一些信息,使这个应用程序,他们告诉我应该使用NSDate和NSCalendar.however我想存储所有信息和用户可以加载时重新打开应用程序,我应该使用SQLite或核心数据?感谢iphone倒数事件
奔,
1. Store your time (NSDate) at the appropriate time.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSDate date] forKey:@"CheckedInTime"];
[defaults synchronize];
当你的应用变得活跃起来: (IE) -
(无效)applicationDidBecomeActive:(UIApplication的*)应用
启动计时器检查时间是否已过期:
self.checkinTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(checkinTimerCheck:) userInfo:nil repeats:YES];
- (void) checkinTimerCheck:(NSTimer *) timer {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDate * checkinTime = [defaults objectForKey:@"CheckedInTime"];
float hours = HOWEVER_MANY_HOURS_NEED_TO_PASS_TO_EXPIRE_IN_SECONDS;
if (hours < 0) {
[self alertUserThatTimeHasExpired];
}
}
无效计时器检查时,您的应用程序变得
- (void)applicationWillResignActive:(UIApplication *)application
问候,
肯