i have two NSDates and i want to check if a third one is between those others. But now, even if i know that the date i want to check is between the others, it says its not. Maybe one of you can help me.So the 开发者_StackOverflow社区if-clause is always TRUE.
Thanks a lot!!
current = [ar objectAtIndex:j];
gameDate = [current gameDate];
gameDate = [gameDate substringToIndex:[gameDate length] - 9];
GameDay = [df dateFromString:gameDate];
if(![GameDay compare:start] == NSOrderedAscending && ![GameDay compare:end] == NSOrderedDescending){
[DateArray addObject:[ar objectAtIndex:j]];
}
You can try simply using the NSDate NSTimeInterval (which is really just a typeDef for double) and comparing like this:
if ([myCheckDate timeIntervalSince1970] < [mybetweenDate1 timeIntervalSince1970] && [myCheckDate timeIntervalSince1970] > [mybetweenDate2 timeIntervalSince1970])
Hope that helps.
精彩评论