가능한 중복 :
Schedule number of Local Notifications성능 문제 (로컬 알림 많은 수의)
내가 scheduleLocalNotification와 성능 문제에 직면하고있다. 많은 지역 알림을 등록하려고합니다. 친구에게는 생일 경보와 같습니다. 테스트를 위해 약 300 개의 알림을 등록하려고 시도했지만 iPhone4가 2 분 이상 걸렸습니다. (iPad2 4 초, iPhone4S 8 초)
다음은 코드입니다.
-(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];
}
운영자가 다시 열 수 있습니까? "중복"은 실제로 로컬 알림 제한을 처리하는 반면이 질문은 성능 문제를 해결합니다. – Mazyod