2010-10-21 62 views
1

大家好
我創建了一個UILocalNotification .... &當我打印下一個火日期

NSLog(@"Notification %@",self.notification) 

它給

Notification <UIConcreteLocalNotification: 0x6f45440> 
{fire date = 2010-10-22 00:09:00 -0700, time zone = America/Vancouver (PDT) offset -25200 
(Daylight), repeat interval = 64, **next fire date** = 2010-10-22 00:10:00 -0700} 

但我想訪問下一個火此通知的日期如何獲得此值?
請任何幫助這一點。

回答

-3

可以從返回的字符串

+2

解析對象的描述*從未*一個好主意,因爲該格式可以在改變未來並破壞你的代碼。相反,總是試圖使用記錄的屬性和方法,以獲得您所需要的信息。 – 2010-12-01 16:47:53

1

UILocalNotification有一個fireDate屬性,您可以使用訪問從[self.notification描述]下一個日期是NSString的和刪除不需要的字符。

-1

只需使用:

NSCalendar *calendar = [NSCalendar currentCalendar];  
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval 

fromDate:self.localNotification.fireDate]; 

NSDate *nextFireDate = [calendar dateFromComponents:comps];