您可以使用此代码,
//This code will give you next date from current date
NSDate *today = [[NSDate alloc] init];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setDay:1]; // you can change this as per your requirement, this will increase +1 date
NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate:today options:0];
// This code will give previous date from current date
NSDate *today1 = [[NSDate alloc] init];
NSCalendar *gregorian1 = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *offsetComponents1 = [[NSDateComponents alloc] init];
[offsetComponents1 setDay:-1]; // you can change this as per your requirement, this will decrease -1 date
NSDate *previousDate = [gregorian1 dateByAddingComponents:offsetComponents1 toDate:today1 options:0];
您可以更改日期,甲酸,与你的愿望日期格式。希望这可以帮助。 快乐编码。
检查下面的帖子,可以解决您的问题 – 2014-10-06 07:31:10