0
我試圖將nsdate增加1個月,但是當它到達年底時,年不會更新(從第一個月開始)?這怎麼解決?NSDate increment
這是我用什麼代碼
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];
感謝它的工作原理:D – user648244 2011-04-04 23:23:00