如何檢查兩個其他NSDate之間是否發(fā)生NSDate我試圖使用NSDate判斷當前日期是否在日期范圍內(nèi)。例如,您可以使用NSDate獲取當前日期/時間:NSDate rightNow = [NSDate date];然后我想用那個日期來檢查它是否在上午9點到下午5點之間。
3 回答

寶慕林4294392
TA貢獻2021條經(jīng)驗 獲得超8個贊
我想出了一個解決方案。如果您有更好的解決方案,請隨意離開,我會將其標記為正確。
+ (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate{ if ([date compare:beginDate] == NSOrderedAscending) return NO; if ([date compare:endDate] == NSOrderedDescending) return NO; return YES;}
- 3 回答
- 0 關(guān)注
- 501 瀏覽
添加回答
舉報
0/150
提交
取消