Mid*_* MP 1 nsdate nsdateformatter ios
目前我正在NSDate
和NSDateFormatter
.
我的问题是我需要find the date after 100 days
用户指定的日期.
目前我正在使用这个硬编码的字符串来查找未来的日期.
calendar.maximumDate = [self.dateFormatter dateFromString:@"20/08/2015"];
Run Code Online (Sandbox Code Playgroud)
但它不是正确的方式,不适用于用户指定的日期.反正有没有实现这个目标?
请帮我.
提前致谢.
像这样:
// How much day to add
int addDaysCount = 100;
// Create and initialize date component instance
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setDay:addDaysCount];
// Retrieve date with increased days count
NSDate *newDate = [[NSCalendar currentCalendar]
dateByAddingComponents:dateComponents
toDate:fromdateHere options:0];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
142 次 |
最近记录: |