Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS8中指定日期的本地通知_Ios_Objective C_Notifications_Xcode6 - Fatal编程技术网

iOS8中指定日期的本地通知

iOS8中指定日期的本地通知,ios,objective-c,notifications,xcode6,Ios,Objective C,Notifications,Xcode6,我希望在特定日期在我的应用程序上显示本地通知,例如,我希望通知在一个月的所有1天都显示 我有这个代码,我如何定制它 //LOcal Notification NSDate *today = [NSDate new]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *offsetCompon

我希望在特定日期在我的应用程序上显示本地通知,例如,我希望通知在一个月的所有1天都显示

我有这个代码,我如何定制它

//LOcal Notification

    NSDate *today = [NSDate new];
    NSCalendar *gregorian =
    [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

    NSDateComponents *offsetComponents = [NSDateComponents new];
    [offsetComponents setDay:???];
    [offsetComponents setHour:10];
    [offsetComponents setMinute:0];

    NSDate *thedate = [gregorian dateByAddingComponents:offsetComponents
                                                  toDate:today options:0];
    UILocalNotification* localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = thedate;
    localNotification.alertBody = @"Hey, il serait temps de faire un point non ? \ue104";
    localNotification.timeZone = [NSTimeZone defaultTimeZone];
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
    //END

公历上的ios8有太多折旧错误,我如何解决

折旧警告不是错误,您仍然可以使用它。按cmd键并单击NSGregorianCalendar将指导您使用什么,而不是不推荐使用的。Xcode显示:FOUNDATION\u EXPORT NSString*const NSGregorianCalendar NS\u CALENDAR\u Deprecated 10\u 4、10\u 10、2\u 0、8\u 0,改用NSCalendarIdentifierGregorian,好的,但是怎么做呢?在哪里?这两个问题以前都被问过:谢谢你,我怎么能测试它?我想你已经有谷歌了!那就学习吧。
//assuming you want to fire the notifiaction on 1st of every month.
 NSInteger desiredWeekday = 1;// it specifies on which day  of month 
  NSRange weekDateRange = [[NSCalendar currentCalendar] maximumRangeOfUnit:NSWeekdayCalendarUnit];
  NSInteger daysInWeek = weekDateRange.length - weekDateRange.location + 1;

  NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
  NSInteger currentWeekday = dateComponents.weekday;
  NSInteger differenceDays = (desiredWeekday - currentWeekday + daysInWeek) % daysInWeek;
  NSDateComponents *daysComponents = [[NSDateComponents alloc] init];
  daysComponents.day = differenceDays;
  NSDate *resultDate = [[NSCalendar currentCalendar] dateByAddingComponents:daysComponents toDate:[NSDate date] options:0];


UILocalNotification* localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = resultDate; 
    localNotification.alertBody = @"Hey, il serait temps de faire un point non ? \ue104";
    localNotification.timeZone = [NSTimeZone defaultTimeZone];

    localNotification.repeatInterval = NSMonthCalendarUnit;// repeat notifiaction after a month
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];