我正在使用以下代码
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = fireDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"Have you seen your Chiropractic this Month?";
localNotification.alertAction = @"Continue";
localNotification.repeatInterval = NSMonthCalendarUnit;
localNotification.applicationIconBadgeNumber = 0;
// Schedule it with the app
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
如何设置“fireDate”,以便此通知仅在每个月的第5个月播放。其次,此代码位于appDelegate.h中。我将如何设置它以便每月只启动一个通知
答案 0 :(得分:1)
我猜这个问题实际上是如何创建一个从
开始的日期对象你可以从这样的事情开始
NSCalendar *calender = [NSCalendar currentCalendar];
calender.timeZone = [NSTimeZone timeZoneWithName:@"GMT"];
NSDateComponents *components = [calender components:NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
components.day = 5;
components.hour = 12;
components.minute = 30;
NSDate *fireDate = [calender dateFromComponents:components];