我试图在使用Eventkit Framework添加事件时将开始日期提前1年。
到目前为止,我已经看过了,做了谷歌搜索并尝试了
controller.event.startDate = [[[NSDate alloc] initWithTimeInterval: 525960];
controller.event.endDate= [[NSDate alloc] init];
我收到一条错误消息
NSDate declares the selector initWithTimeInterval
最佳答案
不要这样做,因为interval = 525960。
而是使用NSCalender,然后通过将1加到当前年份进行操作。
NSCalendar *calendar=[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar] ;
NSDateComponents *components=[[NSDateComponents alloc] init] ;
components.year=1;
NSDate *newDate=[calendar dateByAddingComponents: components toDate:[NSDate date] options: 0];
NSLog(@"Next year : %@", newDate);
关于objective-c - 如何使用EventKit Framework提前一年设置提醒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14110979/