Objective c 多个本地通知问题

Objective c 多个本地通知问题,objective-c,ios7,uilocalnotification,Objective C,Ios7,Uilocalnotification,我想根据来自服务器的通知数安排多个通知,它应该一个接一个地启动。。。 如果count==4,则应触发四个通知 我是iOS的初学者 这是我的密码: 我创建了一个方法,通过传递时间和消息来创建UILocalNotifications + (void)createNotificationWithNumberOfDays:(int)days andMessage:(NSString *)message

我想根据来自服务器的通知数安排多个通知,它应该一个接一个地启动。。。 如果
count==4
,则应触发四个通知

我是iOS的初学者

这是我的密码:


我创建了一个方法,通过传递时间和消息来创建
UILocalNotifications

+ (void)createNotificationWithNumberOfDays:(int)days 
                                andMessage:(NSString *)message 
                                  userInfo:(NSDictionary *)dict{

    NSCalendar *gregorian = 
    [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setDay:days];
//    [components setSecond:days * 2];
    NSDate *dateAlert = 
     [gregorian dateByAddingComponents:components 
                                toDate:[NSDate date] options:0];

    UIApplication *app = [UIApplication sharedApplication];
    UILocalNotification *notifyAlarm = [[UILocalNotification alloc] init];

    if( notifyAlarm ){
        [notifyAlarm setFireDate:dateAlert];
        [notifyAlarm setTimeZone:[NSTimeZone defaultTimeZone]];
        [notifyAlarm setSoundName:@"soundname"];
        [notifyAlarm setAlertBody:message];
        [notifyAlarm setUserInfo:dict];
        [app scheduleLocalNotification:notifyAlarm];
    }
}

听起来单个
UILocalNotifications
之间应该只有第二个区别。因此,您必须在每封邮件中添加
[components setSecond:@1]

几件事1)您已经尝试过什么?请分享您已经完成的代码,以向我们展示您在提问之前已经尝试过这一点,我们非常乐意提供帮助,但您需要先展示您已经尝试过解决这一问题。2) 这与
xcode
IDE无关,仅仅因为您使用的是
xcode
,并不意味着您应该使用该标记,因此我删除了该标记。欢迎来到stackoverflow。同意@Popeye!你需要更准确地告诉我们你已经做了什么,否则就不可能真正提供帮助。谢谢你的快速回复。别介意他们在那边犯错误。下面是我尝试编写的代码appviewcontroller.m-(void)sendNotification{UILocalNotification*localNotification=[[UILocalNotification alloc]init];localNotification.fireDate=[NSDate DateWithTimeIntervalsInnow:5];localNotification.alertBody=@“我们有新鲜蔬菜和水果!”;localNotification.timeZone=[NSTimeZone defaultTimeZone];localNotification.ApplicationConBadgeNumber=[[UIApplication sharedApplication]ApplicationConBadgeNumber]+1;[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];}请将代码添加到问题中。谢谢
+ (void)createNotificationWithNumberOfDays:(int)days 
                                andMessage:(NSString *)message 
                                  userInfo:(NSDictionary *)dict{

    NSCalendar *gregorian = 
    [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *components = [[NSDateComponents alloc] init];
    [components setDay:days];
//    [components setSecond:days * 2];
    NSDate *dateAlert = 
     [gregorian dateByAddingComponents:components 
                                toDate:[NSDate date] options:0];

    UIApplication *app = [UIApplication sharedApplication];
    UILocalNotification *notifyAlarm = [[UILocalNotification alloc] init];

    if( notifyAlarm ){
        [notifyAlarm setFireDate:dateAlert];
        [notifyAlarm setTimeZone:[NSTimeZone defaultTimeZone]];
        [notifyAlarm setSoundName:@"soundname"];
        [notifyAlarm setAlertBody:message];
        [notifyAlarm setUserInfo:dict];
        [app scheduleLocalNotification:notifyAlarm];
    }
}