私のアプリには、友達のリストがあります。3人の友達、これら3人全員に誕生日の詳細があります。彼らのb'daysアラートを表示するためにローカル通知をスケジュールする必要があります。ローカル通知を知っていて処理しましたが、これらの複数の通知をどのように処理しますか?
「forループ」で起動日を設定しています。適切ですか、コードを参照してください。
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
NSDateFormatter *formatter = [[[NSDateFormatter alloc]init]autorelease];
for (int i = 0; i< [delegate.viewController.contactList count] ; i++) {
NSString *birthday = [[myArray objectAtIndex:i]objectForKey:@"birthday"];
[formatter setDateFormat:@"MM/dd/yyyy"];
NSDate *date = [formatter dateFromString:birthday];
localNotif.fireDate = [date dateByAddingTimeInterval:10];
localNotif.timeZone = [NSTimeZone defaultTimeZone];
NSLog(@"local %@",localNotif.fireDate);
}
localNotif.applicationIconBadgeNumber = 1;
NSString *itemName = @“Friend Name";
NSDictionary *userDict = [NSDictionary dictionaryWithObjectAndKey:itemName,@"msg", nil];
localNotif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
私が欲しいのは、この方法では、日付に基づいてすべての友達に通知を設定するだけです。誰かが私が間違っているところを教えてもらえますか、何かが足りない場合は私に知らせてください。