下一个月的,

NSDateFormatter *format=[[[NSDateFormatter alloc] init]autorelease];
[format setDateFormat:@"YYYY-MM-dd"];
NSDate *fromdate=[format dateFromString:date];


NSCalendar *calendar = [[[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar]autorelease];
//NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *componentsToAdd = [[NSDateComponents alloc] init];
// 1 上一个月
if (nextOrPre == 1)
{
[componentsToAdd setMonth:-1];
}
else
{
[componentsToAdd setMonth:1];
}

NSDate *dateAfterMonth = [calendar dateByAddingComponents:componentsToAdd toDate:fromdate options:0];
[componentsToAdd release];
[date setString:[format stringFromDate:dateAfterMonth]];
return date ;

原文地址:https://www.cnblogs.com/guligei/p/3075759.html