2015-07-03 162 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; 
    } 
}