일요일에 사용자가 일요일을 잊어 버렸을 때 월요일 또는 화요일 또는 한 달에 애플리케이션을 열면 데이터가 새로 고쳐 져야하는 매주 일요일에 데이터를 새로 고치는 방법.일요일마다 데이터를 새로 고치는 방법
-(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
일요일의 배열을 생성하고 그 날짜를 정기적으로 확인하십시오. 한 날짜가 전달/일치되면 데이터 세트를 업데이트하고 해당 날짜를 배열에서 제거합니다. –