Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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:
Code:
- (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:
Code:
 NSMutableArray * notifications = [[[UIApplication sharedApplication] scheduledLocalNotifications]mutableCopy];
NSLog(@"%i", notifications.count);
But, the log always returns 0. Any thoughts?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.