1

I am trying to use this calendar component and my task is to make disabled visually and technically all dates before today's date. User can switch between months also and I need to have all dates before today disabled, even if it will be date of a few years ago. disabledDateTextColor and disabledDateBackgroundColor types are also defined for this calendar but no dates calculation methods. I am reading NSDate documentation and looks like I can't do that directly, using system method (i mean method what return array of dates before or after date or something similar). Looks like adding all existing days before today to NSArray and marking them as disabled before drawing calendar is an obvious overkill, isn't it?

4

1 回答 1

2

在我以前的应用程序中,我使用了这种方法

switch ([dateOne compare:dateTwo]) {
case NSOrderedAscending:
    // dateOne is earlier in time than dateTwo
    break;
case NSOrderedSame:
    // The dates are the same
    break;
case NSOrderedDescending:
    // dateOne is later in time than dateTwo
    break;
}

两个日期格式化程序都应该类似阅读下面链接中的实例方法以获取更多信息

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDate/compare

于 2013-08-01T11:28:45.253 回答