毎月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];