use*_*244 0 iphone sdk xcode objective-c
我试图将nsdate增加1个月,但是当它到达年底时,年份不会更新(从第一个月开始再次)?怎么能修好?
这是我用过的代码
NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *comp = [[[NSDateComponents alloc] init] autorelease];
[comp setMonth: 1];
NSDate* newDate = [gregorian dateByAddingComponents:comp toDate:oldDate options:NSWrapCalendarComponents];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
823 次 |
| 最近记录: |