SQLite データベースがあります。
日付が変わったときにデータベースに行を挿入したい。
を使用する必要があることは知っていますUILocalNotification
が、方法がわかりません。
他の方法は NSTimer をバックグラウンドで実行することですが、私はそうしたくありません。
私が試したチュートリアルから:
UIApplication* app = [UIApplication sharedApplication];
NSDate *date = [NSDate date];
// create the notification and then set it's parameters
UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease];
if (notification)
{
notification.fireDate = date;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.repeatInterval = 0;
notification.alertBody = @"DONE:";
// this will schedule the notification to fire at the fire date
[app scheduleLocalNotification:notification];
// this will fire the notification right away, it will still also fire at the date we set
[app presentLocalNotificationNow:notification];
}
しかし、私のアプリでは、アプリがバックグラウンドまたはフォアグラウンドにあるデータベースに挿入する必要があります。日付が変わるときに挿入する必要があります。