Objective C - get the following day from today (tomorrow)

后端 未结 3 1547
青春惊慌失措
青春惊慌失措 2020-11-29 06:51

How can I check to see if a date is inherently TOMORROW?

I don\'t want to add hours or anything to a date like today, because if today is already 22:59,

3条回答
  •  失恋的感觉
    2020-11-29 07:23

    In iOS 8 there is a convenience method on NSCalendar called isDateInTomorrow.

    Objective-C

    NSDate *date;
    BOOL isTomorrow = [[NSCalendar currentCalendar] isDateInTomorrow:date];
    

    Swift 3

    let date: Date
    let isTomorrow = Calendar.current.isDateInTomorrow(date)
    

    Swift 2

    let date: NSDate
    let isTomorrow = NSCalendar.currentCalendar().isDateInTomorrow(date)
    

提交回复
热议问题