Possible duplicate:
Local Notification Schedule Number
I ran into a performance issue with schedLocalNotification. I am trying to register a large number of local notifications. Itβs like money reminders for friends. For the test, I tried to register about 300 notifications, but my iPhone4 took more than 2 minutes. (iPad2 4 seconds, iPhone4S 8 seconds)
Here is the code.
-(void)setAllBirthdaysSchedule { Class cls = NSClassFromString(@"UILocalNotification"); if (cls == nil) { return ; } NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [[UIApplication sharedApplication] cancelAllLocalNotifications]; if (prototypeNotification == nil) { prototypeNotification = [[UILocalNotification alloc] init]; prototypeNotification.repeatCalendar = [NSCalendar currentCalendar]; prototypeNotification.repeatInterval = NSYearCalendarUnit; prototypeNotification.timeZone = [NSTimeZone defaultTimeZone]; prototypeNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:0]; prototypeNotification.applicationIconBadgeNumber = 0; prototypeNotification.alertBody = NSLocalizedString(@"Body", nil); prototypeNotification.alertAction = NSLocalizedString(@"Action", nil); } NSArray* arr = [self getAllBirthday]; for (User* user in arr) { UILocalNotification *notif = [prototypeNotification copy]; notif.fireDate = user.birthday; [[UIApplication sharedApplication] scheduleLocalNotification:notif]; [notif release]; } [pool release]; }
source share