下面是我的比较代码:比较如果两个的NSDate对象是相同
int countTrue = 0;
//NSDate *datee = [[self.reminderResultsArray objectAtIndex:0] date];
for(int i = 0; i < self.reminderResultsArray.count; i++){
if([[NSCalendar currentCalendar] isDate:self.actualSelectedDate inSameDayAsDate:[[self.reminderResultsArray objectAtIndex:i] date]]){
countTrue++;
NSLog(@"Count true: %d", countTrue);
}
}
下面是在我的self.reminderResults.array
数据:
(LLDB)PO [[self.reminderResultsArray objectAtIndex:1 ]日期] 2017年6月2日九时38分35秒0000
(LLDB)PO [[self.reminderResultsArray objectAtIndex:0]日期] 2017年5月27日9点37分48秒0000
(LLDB)PO [[self.reminderResultsArray objectAtIndex:1]日期] 2017年6月2日9点38分35秒0000
(LLDB)PO [[self.reminderResultsArray objectAtIndex:2]日期] 2017年6月2日10时09分48秒0000
(LLDB)PO [[self.reminderResultsArray objectAtIndex:3]日期] 2017年6月2日十点12分30秒0000
(lldb)po [[self.reminderResultsArray objectAtIndex:4] date] 2017-06-03 08:49:33 +0000
我self.actualSelectedDate
值:
po self.actualSelectedDate
2017-06-02 16:00:00 +0000
通过权,countTrue
值应该是3,而是它只是回归1.我的代码的任何问题的价值?
你只关心日期部分而不想忽略时间部分? –
@AndréSlotta只有日期部分 – SPUDERMAN