如何获得每个月的第 5 个日期。到目前为止,我知道如何获取当前日期。我只想在每个月的 5 日发出本地通知。
这是我的代码:
UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
if (!localNotification){
return;
}
NSDate *date = [NSDate date];
NSDate *dateToFire = ?; // please give me logic to find out 5th of evry month
[localNotification setFireDate:dateToFire];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
NSArray *array = [NSArray arrayWithObjects:@"Value 1", @"Value 2", nil];
NSDictionary *data = [NSDictionary dictionaryWithObject:array forKey:@"payload"];
[localNotification setUserInfo:data];
[localNotification setAlertBody:@"Incoming Local Notification" ];
[localNotification setAlertAction:@"Open App"];
[localNotification setHasAction:YES];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];