Ios 本地通知设置特定的火灾日期

Ios 本地通知设置特定的火灾日期,ios,objective-c,localnotification,Ios,Objective C,Localnotification,我正在制作一个具有本地通知功能的iOS应用程序。我要做的是将本地通知的点火日期设置为特定日期。例如:通知将于2014年7月28日上午10:31发出 [localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:10]]; 这就是我现在所拥有的,它将应用程序启动后的点火日期设置为10秒。那么我该如何设定一个确切的日期呢 提前谢谢 您可以通过以下组件创建日期: NSDateComponents *dateComponents

我正在制作一个具有本地通知功能的iOS应用程序。我要做的是将本地通知的点火日期设置为特定日期。例如:通知将于2014年7月28日上午10:31发出

[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:10]];
这就是我现在所拥有的,它将应用程序启动后的点火日期设置为10秒。那么我该如何设定一个确切的日期呢


提前谢谢

您可以通过以下组件创建日期:

NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.minute = 31;
dateComponents.hour = 10;
...
NSDate *fireDate = [[NSCalendar autoupdatingCurrentCalendar] dateFromComponents:dateComponents];

要补充的是,您必须使用24小时的时间。