小智 4
要查看某个日期是否是“明天”,请执行以下操作。
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDate *currentDate = [NSDate date];
NSDateComponents *comps = [[NSDateComponents alloc] init];
// set tomorrow (0: today, -1: yesterday)
[comps setDay:1];
NSDate *dateTomorrow = [calendar dateByAddingComponents:comps
toDate:currentDate
options:0];
[comps release];
Run Code Online (Sandbox Code Playgroud)
其余的应该是相当明显的。
HTH。
| 归档时间: |
|
| 查看次数: |
3269 次 |
| 最近记录: |