PDA

View Full Version : Show set local notifications in table view




newtoiphonesdk
Feb 10, 2012, 10:52 PM
Trying to get a tableview class set up to display local notifications that the user can set within the application.
The view controller that sets the notification:
- (void)scheduleNotification {

[reminderText resignFirstResponder];

Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {

UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [datePicker date];
notif.timeZone = [NSTimeZone defaultTimeZone];

notif.alertBody = reminderText.text;
notif.alertAction = @"Ok";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;

NSInteger index = [scheduleControl selectedSegmentIndex];
switch (index) {
case 1:
notif.repeatInterval = NSDayCalendarUnit;
break;
case 2:
notif.repeatInterval = NSWeekCalendarUnit;
break;
default:
notif.repeatInterval = 0;
break;
}

NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text
forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;

[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
}
viewDidLoad of the tableview class:
NSMutableArray * notifications = [[[UIApplication sharedApplication] scheduledLocalNotifications]mutableCopy];
NSLog(@"%i", notifications.count);
But, the log always returns 0. Any thoughts?



jnoxx
Feb 13, 2012, 02:37 AM
A wild guess, before going through all your code, is your firedate, AFTER you are logging the message? :)