Objective c 多个计划的本地通知

Objective c 多个计划的本地通知,objective-c,Objective C,是否可以在objective-c中生成多个计划的LocalNotification NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *dateComponent = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCale

是否可以在objective-c中生成多个计划的LocalNotification

NSCalendar *calendar = [NSCalendar currentCalendar];
    NSDateComponents *dateComponent = [calendar components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate:[NSDate date]];

    [dateComponent setYear:2014];
    [dateComponent setMonth:6];
    [dateComponent setDay:28];
    [dateComponent setHour:10];
    [dateComponent setMinute:48];

    UIDatePicker *dp = [[UIDatePicker alloc]init];
    [dp setDate:[calendar dateFromComponents:dateComponent]];

    UILocalNotification *notification = [[UILocalNotification alloc]init];
    [notification setAlertBody:@"Hello"];
    //[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:3]];
    [notification setFireDate:dp.date];
    [notification setTimeZone:[NSTimeZone defaultTimeZone]];
    notification.soundName = UILocalNotificationDefaultSoundName;
    notification.soundName = @"Song2.caf";
    notification.applicationIconBadgeNumber = -1;
    [application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
我试着重复这个过程,但没有成功。我只做了最后一个,所以我只能做一个计划的本地通知。

是的

使用

为每个通知对象设置通知而不是setScheduledLocalNotifications:[NSArray arrayWithObject:notification]

如果需要设置大量通知,可以在初始化和设置通知后将所有通知添加到通知数组:

[application setScheduledLocalNotifications:[NSArray arrayWithObjects:notification1, notification2, notification3]];
[application setScheduledLocalNotifications:[NSArray arrayWithObjects:notification1, notification2, notification3]];