私はそのようなものを1つの配列にしています:
_combinedBirthdates(
"03/05/2013",
"09/22/1986",
"03/02/1990",
"03/02",
"08/22/1989",
"11/02/1990",
"07/08",
"08/31/1990",
"05/13",
"07/11/2007",
"10/07/2010",
"02/20/1987")
今日の日付が上記の配列の日付と同じである場合、ローカル通知が必要です
通知には次のロジックを使用しました。
NSLog(@" _combinedBirthdates%@",_combinedBirthdates);
NSDateFormatter *Formatter1 = [[NSDateFormatter alloc] init];
[Formatter1 setDateFormat:@"MM/dd"];
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
NSDate *date1 =[NSDate date];
NSString *string =[Formatter1 stringFromDate:date1];
NSDate *todaydate =[Formatter1 dateFromString:string];
for (int i=0;i<_combinedBirthdates.count;i++)
{
NSDate *date =[Formatter1 dateFromString:[_combinedBirthdates objectAtIndex:i ]];
if(date == todaydate){
localNotif.fireDate = date;
localNotif.alertBody = @"birthdate notification";
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
今私の質問:
- このコードは大丈夫ですか?
- このコードをテストするためのデバイスが必要ですか、それともシミュレーターでテストできますか?
- 通知はいつ表示されますか?午前12時?
- アプリケーションを閉じると通知が表示されますか?
- コードに問題がある場合は、コードを変更してください。