NSGregorianCalendar已弃用

时间:2016-12-16 11:56:18

标签: objective-c xcode nscalendar

我有问题。我想知道如何删除警告? 谢谢 `

NSDate *fireDate = [picker_date date];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setMinute:-10];
NSDate *heure_notification = [gregorian dateByAddingComponents:offsetComponents toDate:fireDate options:0];


UILocalNotification *local_rappel_notification = [[UILocalNotification alloc]init];
local_rappel_notification.fireDate = heure_notification;
local_rappel_notification.alertBody = @"VOUS AVEZ  UN VOL MAINTENANT DANS 10 MIN!!";
local_rappel_notification.timeZone = [NSTimeZone defaultTimeZone];
local_rappel_notification.soundName = UILocalNotificationDefaultSoundName;
local_rappel_notification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;

[[UIApplication sharedApplication ]scheduleLocalNotification:local_rappel_notification];

}`warnig photo

1 个答案:

答案 0 :(得分:10)

如果您阅读了错误消息(使视图更宽),您会看到自iOS 8以来NSGregorianCalendar现已替换为NSCalendarIdentifierGregorian

因此请使用NSCalendarIdentifierGregorian