我有本地通知的代碼,我有一個scheduleNotification和clearNotification使用我自己的方法。這些是代碼:取消特定的UILocalNotification
- (void)clearNotification {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
- (void)scheduleNotification {
[reminderText resignFirstResponder];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [[datePicker date] dateByAddingTimeInterval:-30];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Evaluation Planner";
notif.alertAction = @"Details";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
}
這些代碼運行良好,但現在我想知道如何知道它將刪除哪個通知對象。我想爲通知創建一個ID,也就是說,一個ID相當於一個通知。但我不知道我應該在哪一部分做到這一點。另外,我需要找到一種方法將所有這些都包含在plist中。
希望有人能幫助我。謝謝。
只是想補充說,命名變量「不」會產生錯誤。 – OthmanT