毎週日曜日にデータを更新するには、日曜日を忘れて月曜日、火曜日、または月にアプリケーションを開いた場合、データをリフレッシュする必要があります。すべての日曜日にデータを更新する方法
-(void) checkRefreshGoals:(int)sectionIndex rowIndex:(int)rowIndex
{
NSDateFormatter * formatter = [NSDateFormatter new];
[formatter setDateFormat:@"yyyy-MM-dd"];
NSString * currentDateString = [formatter stringFromDate:[NSDate date]];
NSString * initialNotificationDate = [formatter stringFromDate:refreshDate];
NSDate *currentDate = [formatter dateFromString:currentDateString];
NSDate *refreshDate = [formatter dateFromString:initialNotificationDate];
if ([refreshDate compare:currentDate] == NSOrderedDescending)
{
NSLog(@"date1 is later than date2");
isGoalsRefreshed = NO;
}
else if ([refreshDate compare:currentDate] == NSOrderedAscending)
{
NSLog(@"date1 is earlier than date2");
if (sameDay == YES)
{
isGoalsRefreshed = YES;
[self refreshDataOnSunday:sectionIndex rowIndex:rowIndex];
}
else if (noOfDaysCount > 7)
{
isGoalsRefreshed = YES;
[self refreshDataOnSunday:sectionIndex rowIndex:rowIndex];
}
else
{
isGoalsRefreshed = NO;
}
}
else
{
NSLog(@"dates are the same");
isRefreshed = NO;
}
}
私の開始日は木曜日であり、日曜日をスキップして月曜日に行くとデータが更新されないので、最初の段階ではリフレッシュされません。
あなたは 'refreshDate'または' noOfDaysCount'の設定方法を表示しません。 NSUserDefaultsにフラグを保存して、以前にアプリが実行されたかどうかを確認することができます。それが時間に関係なくリフレッシュを実行していない場合。それがあなたが求めているものでない場合は、もっと多くの情報/コードが他の人に可能な答えを与えるように考えてください。 – Flexicoder
日曜日の配列を生成し、それらの日付を定期的にチェックしてください。 1つの日付が渡され/一致する場合は、データセットを更新し、その日付も配列から削除します。 –