2015-07-03 166 views
1

我正在研究xcode 6中的虛擬項目並創建本地通知。我已經創建並刪除了這些本地通知。現在我想編輯一個特定的通知。如何在iphone中編輯本地通知sdk objective c

+0

你嘗試過什麼到目前爲止?如果是這樣,給我們看一些代碼,這樣我們可以更好地幫助你。閱讀更多關於[如何提出一個很好的問題](http://stackoverflow.com/help/how-to-ask)。 – methode

回答

1

您無法更改已安排的通知。
您必須取消並使用所需的新數據重新創建它。

你可以要求安排UILocalNotifications當前:

NSArray *scheduledNotifications = [[UIApplication sharedApplication] scheduledLocalNotifications]; 

循環數組,做一個檢查,如果其通知您需要更改:

for (UILocalNotification *notification in scheduledNotifications) 
{ 
    //Get the ID you set when creating the notification 
    NSDictionary *userInfo = notification.userInfo; 
    NSNumber *someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject = [userInfo objectForKey:@"someKey"]; 

    if (someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject == someCheckYouHaveToDoHere) 
    { 
     [[UIApplication sharedApplication] cancelLocalNotification:notification]; 
     //Re-create the localnotification with new data and the someValueYouGaveWhenCreatingCouldBeAnIdentifierOfAnObject 

     break; 
    } 
}