2014-07-20 45 views
1

我正在製作一個具有本地通知功能的iOS應用程序。我想要做的是將本地通知的啓用日期設置爲特定日期。例如:通知將於2014年7月28日上午10點31分結束。本地通知設置特定的火災日期

[localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:10]]; 

這就是我現在所設置的應用程序啓動後10秒的啓動日期。那麼如何將其設置爲確切日期?

在此先感謝!

回答

1

你可以這樣創建組件的日期:

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

我想補充,你必須使用24小時時間。 – msweet168